comp.lang.ada
 help / color / mirror / Atom feed
From: Aurele <aurele.vitali@gmail.com>
Subject: Re: zLibAda vs ZipAda (which should I use, if any)?
Date: Sat, 27 Aug 2016 09:31:29 -0700 (PDT)
Date: 2016-08-27T09:31:29-07:00	[thread overview]
Message-ID: <5d5c2b37-148a-46e5-9b12-479253704595@googlegroups.com> (raw)
In-Reply-To: <5d747db1-ad5d-4de6-8c99-e520a6b39a08@googlegroups.com>

Hi Gautier, I think your GID packages will provide the services I need. Very well done by the way.  

Maybe you can save me some time and guide me on its use for my needs.  I've inserted some code below that show how I'll load the images from the zip file using Zip-Ada, I arrange the data (not shown), and then I need to call GID procedure to load as Handle.

Any comments or ideas? 

declare

  package ASU renames Ada.Strings.Unbounded;

  type Entry_ID is new Integer range -1..Integer'Last;

  type iEntry is record
    Texture_ID : ZipFile.Entry_ID;
    FullName   : Ada.Strings.Unbounded.Unbounded_String;
    Directory  : Ada.Strings.Unbounded.Unbounded_String;
    EntryName  : Ada.Strings.Unbounded.Unbounded_String;
    Extension  : Ada.Strings.Unbounded.Unbounded_String;
  end record;
  type iEntryEntry_Ptr is access all ZipFile.iEntry;

  subtype iEntry_Array_Size is Entry_ID;

  type iEntry_Array is array ( iEntry_Array_Size range <> ) of aliased ZipFile.iEntry;
  type iEntry_Array_Ptr is access all ZipFile.iEntry_Array;

  type Information is record
    File_Location   : Ada.Strings.Unbounded.Unbounded_String;
    File_Name       : Ada.Strings.Unbounded.Unbounded_String;
    Total_Entries   : Natural;
    Texture_Entries : Natural;
    Data_Ptr        : ZipFile.iEntry_Array_Ptr;
  end record;
  type Information_Ptr is access all ZipFile.Information;

  Zip_File_Name         : constant String := "Textures.zip";
  Zip_File_Entries      : iEntry_Array_Size;

  lpTexture_Array       : aliased iEntry_Array_Ptr;
  lpTexture_Info        : aliased Information_Ptr

  Local_Index           : Entry_ID;

  ZipFileInfo           : Zip.Zip_Info;
  FileType              : UnZip.Streams.Zipped_File_Type;

-----------------------------------------------------------------
begin

  Zip.Load( ZipFileInfo, Zip_File_Name );

  Zip_File_Entries := iEntry_Array_Size( Zip.Entries( ZipFileInfo ) );

  lpTexture_Array  := new ZipFile.iEntry_Array( 1..Zip_File_Entries );
  lpTexture_Info   := new ZipFile.Information;

  -- Scan procedure not shown here but is straight forward...
  Scan( ZipFileInfo, FileName, Info_Ptr ); -- FILL INFO_PTR

  -- Simple test....  try to retrieve an image at index = 10

  Local_Index := 10; -- TEST: image at index = 10

  UnZip.Streams.Open
    ( File         => FileType,
      Archive_Info => ZipFileInfo,
      Name  => ASU.To_String( Info_Ptr.Data_Ptr( Local_Index ).FullName ) 
     );

  -- ???????????????????????????????????????????????????????
  -- LoadImage is below, no idea yet what has to be done

  LoadImage( FileNeme => Info_Ptr.Data_Ptr( Local_Index ).EntryName,
             FileExt  => Info_Ptr.Data_Ptr( Local_Index ).Extension,
             FullName => Ada.Streams.Stream_IO.Stream_Access( UnZip.Streams.Stream( FileType ) ) );

  UnZip.Streams.Close( FileType );

end;


-----------------------------------------------------------------
- TBD: Call "GID" procedure to load image (DIB or BMP (bitmap))

type Hande is access all System.Address;  
hBitmap : Hande := NULL;

procedure LoadImage ( FileName : Ada.Strings.Unbounded.Unbounded_String;
                      FileExt  : Ada.Strings.Unbounded.Unbounded_String;
                      FullName : Ada.Strings.Unbounded.Unbounded_String ) is
begin
                   -- --------------------------
  hBitmap := ?;    -- Call GID directly here ??? Steps ????
                   -----------------------------
end LoadImage;

-----------------------------------------------------------------

Cheers and thanks
Aurele


  reply	other threads:[~2016-08-27 16:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25 20:17 zLibAda vs ZipAda (which should I use, if any)? Aurele
2016-08-25 21:02 ` Qun-Ying
2016-08-25 21:33 ` Jeffrey R. Carter
2016-08-25 22:07 ` Aurele
2016-08-25 23:07 ` Aurele
2016-08-25 23:43   ` gautier_niouzes
2016-08-25 23:55     ` Aurele
2016-08-26  0:18       ` gautier_niouzes
2016-08-26  1:44         ` Aurele
2016-08-26 12:36           ` gautier_niouzes
2016-08-26 14:23             ` Aurele
2016-08-26 15:16               ` gautier_niouzes
2016-08-26 15:46                 ` Jeffrey R. Carter
2016-08-26 16:05                 ` Aurele
2016-08-26 23:04                   ` Aurele
2016-08-27  5:30                     ` gautier_niouzes
2016-08-27 11:52                       ` Aurele
2016-08-27 16:31                         ` Aurele [this message]
2016-08-27 19:15                           ` gautier_niouzes
2016-08-27 19:33 ` Aurele
2016-08-27 20:16   ` Aurele
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox