Results 1 to 10 of 34

Thread: BeRoPNG - A very tiny but complete PNG loader

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Quote Originally Posted by Cybermonkey View Post
    What about the Vampyre Imaging Library? It can handle lots of more formats.(JPEG, BMP,GIF etc.) I use it in my EGSL interpreter project and it works pretty well. But of course, if you only need PNG support ...
    BeRoPNG is designed for small binarysize projects and for embedded projects on embedded devices with limited resources. For example my android game FoembJump uses BeRoPNG together with OpenGL ES 2.0. I'm demoscener and a Farbrausch member, so I've fondness for small sized stuff
    Last edited by BeRo; 16-07-2011 at 06:43 PM.

  2. #2
    I've uploaded a new pure pascal version under the same url http://rootserver.rosseaux.net/stuff/BeRoPNG.pas , which's a bit faster and also compatible to Delphi XE3 & XE4 now.

    And the other http://rootserver.rosseaux.net/stuff...oidSpecial.pas variant fallbacks to cpng (a wrapper unit to the on ARM Android faster c-based libpng implementation, which's a bit for Android's own libpng.so modified png.pas from FPC, so you do need http://rootserver.rosseaux.net/stuff/cpng.pas ), if you're building for the Android target, otherwise the pure pascal code part will be used, if you're building for other targets than Android.

  3. #3
    I tried the pure pas version in freepascal, works nicely I'd add a comment that ImageData is a PPNGPixel for clarity, not that it mattered much.

  4. #4
    I feintly remembered reading long time ago, that FPC PNG would have some non-free licence. But now that i tried to find information, i found nothing. All FPC graphics seem to be of same modifiedLGPL that all the other code. But is FPC implementation heavier than this? Maybe it's coming at the cost of supporting more formats, i don't know. I went through all PNG related source files i could find, and there were none licence differences.

  5. #5
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    I think that while the full blown libs might support more image types, something like BeroPNG is a far better choice in order to avoid library dependencies, you're going to to be able to load 9x% of the PNGs you find using it and you're defining your own content usually.

    There might be some differences in speed but it's negligable, only the most chuggy old iphones are going to show much difference between some native arm lib or arm compiled bero.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  6. #6
    Sorry, I know this is an old thread but I tried BeRoPNG to work with ptcgraph. This is my (simple) example:
    Code:
    var
      f: file;
      fsize: longword;
      buffer: pbyte;  
      ImageData: PPNGPixel;
      ImageWidth,
      ImageHeight:longint;
        gd,gm:smallint;
    BEGIN
      AssignFile(f, 'bluepointer.png');
      Reset(f, 1);
      fsize := FileSize(f);
      buffer := getmem(fsize);
      blockread(f, buffer^, fsize);
      CloseFile(f);
    
      BeRoPNG.LoadPNG(buffer, fsize, ImageData, ImageWidth, ImageHeight, false);
      
      Gd:=D16bit;
      Gm:=m800x600;
      InitGraph(Gd, Gm, 'Test'); 
      
      
       if GraphResult <> grOk then begin
             Writeln('Graphics error: ', GraphErrorMsg(ErrorCode));
        Halt(1);
        end;
      
      putimage (10,10,imageData^,1);
      delay (2000);
      closegraph;
      
      
      freemem(buffer);
      freemem(ImageData);
        
       
    END.
    But the result isn't correct (see the attached screenshot). I think the problem is that ptcgraph uses a 16 bit colour format with no alpha channel. Any ideas how this can work?
    beropngtest.jpg
    Best regards,
    Cybermonkey

  7. #7
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Cybermonkey: I've run into this myself quite a few times. Try open the image in gimp or something and fiddle a bit with the compression options when you export. This usually fixes things for reasons I don't fully understand...

    (Though reading your suspicion I guess it might be because GIMP adds an alpha channel during the export? )
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

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
  •