Results 1 to 6 of 6

Thread: Allegro.pas - alpng?

  1. #1

    Allegro.pas - alpng?

    I'm using Allegro.pas for allegro 4.4, but it is missing one certain file - alpng. I can't use PNGs without it and TGA doesn't offer as good compression as PNG does. Do you know where can I download this for Allegro.pas? I'd rather not switch to another framework like JEDI-SDL since for me coding with SDL is a chore and coding with allegro is a joy .

    Also I find it strange that we don't have board for Allegro.pas in libraries and tools section. We have for JEDI-SDL, we have for some obscure game libraries (most of which are discontinued, and one is even discontinued! ).

  2. #2
    It is true that there is no special forum for Allegro.pas but there is a thread from its author and you can find it here:
    http://www.pascalgamedevelopment.com...egro-pas/page2
    Unfortunately author also mentioned in one post that his atempt on adding PNG support failed.

  3. #3

  4. #4
    For once, it seems confusing to use. Secondly, I don't see how I can use it to directly load PNG into Allegro.pas' al_Bitmapptr structure.

  5. #5
    As Silver Warrior said, I tried it but I failed.

    Unfortunatelly, Allegro 4.x internals are quite obscured, and the library wasn't designed to be used in other languages than C and C++. That's why I didn't ported any of the original add-ons included with Allegro 4.4 (I tried to port AllegroGL too ).

    Also I tried to use BeRoPNG but I failed too. It was quite confusing.

    Now, I'll answer your message here.
    No signature provided yet.

  6. #6
    There's only one function to use and you need to load the png file into memory before calling it. It'll return the image in an RGBA array. Example:
    Code:
    var
      f: file;
      fsize: longword;
      buffer: pbyte;  
      ImageData: PPNGPixel;
      ImageWidth,
      ImageHeight:longint;
    begin
      AssignFile(f, 'some.png');
      Reset(f, 1);
      fsize := FileSize(f);
      buffer := getmem(fsize);
      blockread(f, buffer^, fsize);
      CloseFile(f);
    
      BeRoPNG.LoadPNG(buffer, fsize, ImageData, ImageWidth, ImageHeight, false);
      writeln(ImageWidth, 'x', ImageHeight);       
      freemem(buffer);
      freemem(ImageData);
    I don't know allegro, but looks like the only thing you need to do is to create a 32 bit bitmap (al_bitmap) and copy the read data into its line pointers (see https://www.allegro.cc/manual/4/api/...allegro/bitmap )

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •