Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 38

Thread: PNG library that works on Win32, Linux and MacOS X...

  1. #21

    PNG library that works on Win32, Linux and MacOS X...

    It compiles on Linux. Only a few warnings:

    Code:
    libpng.pas(1629,30) Warning: Mixing signed expressions and longwords gives a 64bit result
    libpng.pas(1635,44) Warning: Mixing signed expressions and longwords gives a 64bit result
    libpng.pas(1642,30) Warning: Mixing signed expressions and longwords gives a 64bit result
    libpng.pas(1648,47) Warning: Mixing signed expressions and longwords gives a 64bit result
    But I wouldn't have a clue how to test it. Those libpng functions look pretty complicated. It would be nice to have a demo program, or a simple-to-use class that wraps everything up.
    [size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]

  2. #22

    PNG library that works on Win32, Linux and MacOS X...

    I think the simplest test would be something like this...
    [pascal]
    program PngTest;

    {$APPTYPE CONSOLE}

    var
    temp : string;
    FPngStruct : png_structp;
    FPngInfo : png_infop;
    begin
    temp := png_get_libpng_ver ( nil );
    WriteLn( 'Version : ' + temp );
    FPngStruct := png_create_read_struct( PNG_LIBPNG_VER_STRING, nil, nil, nil );
    if assigned( FPngStruct ) then
    begin
    FPngInfo := png_create_info_struct( FPngStruct );
    if assigned( FPngInfo ) then
    begin
    WriteLn( 'We can start decoding now' );
    end
    else
    begin
    WriteLn( 'Failed to Create PngInfo struct!' );
    end;
    end
    else
    begin
    WriteLn( 'Failed to Create PngStruct!' );
    end;

    ReadLn;
    end.
    [/pascal]

    If you get the *start decoding* message then everything is else should just work. The steps after that would involve introducing call back functions for reading the PNG file.
    If this works for you, I can send you a more complete JEDI-SDL example.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #23

    PNG library that works on Win32, Linux and MacOS X...

    Linking errors! OK, so first of all, you need to rename libPng.so to libpng.so, keep it all lower-case. Second, you need to add zlib to the uses clause. After that, the following linking errors remain:

    Code:
    libpng.o&#40;.text+0xb1&#41;&#58; In function `LIBPNG_PNG_SIG_BYTES$$PNG_BYTEP'&#58;
    &#58; undefined reference to `png_sig_bytes'
    libpng.o&#40;.text+0x411&#41;&#58; In function `LIBPNG_PNG_GET_SCAL_S$POINTER$PNG_INFOP$LONGINT$PNG_CHARPP$PNG_CHARPP$$LONGWORD'&#58;
    &#58; undefined reference to `png_get_sCAL_s'
    libpng.o&#40;.text+0x871&#41;&#58; In function `LIBPNG_PNG_SET_ITXT$POINTER$PNG_INFOP$PNG_TEXTP$LONGINT'&#58;
    &#58; undefined reference to `png_set_itxt'
    libpng.o&#40;.text+0x9a1&#41;&#58; In function `LIBPNG_PNG_SET_SCAL_S$POINTER$PNG_INFOP$LONGINT$PCHAR$PCHAR'&#58;
    &#58; undefined reference to `png_set_sCAL_s'
    /usr/lib/libpng.so&#58; undefined reference to `pow'
    pngtest.pp&#40;32,1&#41; Error&#58; Error while linking
    The undefined reference to `pow' can be fixed by adding {$LINKLIB m} to your libpng unit (alternatively I can just add -lm to my compiler command-line). If I comment out the declarations to the other 4 functions, I can compile it fine. And when I run it, everything works, I see the "We can start decoding now" message. I have version 1.2.12 of libpng.
    [size=10px]&quot;In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it&#39;s the exact opposite.&quot; -- Paul Dirac[/size]

  4. #24

    PNG library that works on Win32, Linux and MacOS X...

    Oh yeah, you are aware that Free Pascal has a unit for the libpng library? It's called 'png'. It compiles fine with your test program, as long as I add the -lm parameter. I guess you also want Delphi compatibility, though.
    [size=10px]&quot;In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it&#39;s the exact opposite.&quot; -- Paul Dirac[/size]

  5. #25

    PNG library that works on Win32, Linux and MacOS X...

    Thanks for testing it out on Linux Cragwolf. Yes the idea is that it should be Delphi/Kylix friendly as well.

    Ok I have removed png_sig_bytes and png_set_itxt and IFDEFed png_get_sCAL_s and png_set_sCAL_s.

    Can you please clarify why I need zlib and where is it picking up the reference to "pow" as that does not exist anywhere in the source code?
    I'm trying to avoid adding {$LINKLIB m} and the unit zlib, unless there is a really good reason to do so. Under Linux wouldn't Zlib be another dynamically linked shared object or are you statically linking it by adding zlib to the uses clause?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #26

    PNG library that works on Win32, Linux and MacOS X...

    I have no idea why the compiler complained about requiring zlib and libm earlier this morning when I tried it. Now even after deleting everything and starting again, it all works fine. Just take care of those four functions like you have, and use lower-case on libpng.so and all is good.
    [size=10px]&quot;In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it&#39;s the exact opposite.&quot; -- Paul Dirac[/size]

  7. #27

    PNG library that works on Win32, Linux and MacOS X...

    phew I thought there was some magic going on somewhere. Thanks again cragwolf. I'm just trying to create a proper zlib.dll and libpng.dll on Win32 at the moment and it's not easy as I'm using Borland C/C++ compilers.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  8. #28

    PNG library that works on Win32, Linux and MacOS X...

    hi cragwolf,
    I've uploaded a new version of libpng.pas with the modifications you mentioned @ http://jedi-sdl.pascalgamedevelopmen...les/libpng.zip.
    It's also version 1.2.16 now.

    When you have a spare moment, could you give it a quick test.


    Thanks.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  9. #29

    PNG library that works on Win32, Linux and MacOS X...

    Works fine, fpc 2.0.4, Linux. Just the same old warnings about mixing different types:

    Code:
    libpng.pas&#40;1630,30&#41; Warning&#58; Mixing signed expressions and longwords gives a 64bit result
    libpng.pas&#40;1636,44&#41; Warning&#58; Mixing signed expressions and longwords gives a 64bit result
    libpng.pas&#40;1643,30&#41; Warning&#58; Mixing signed expressions and longwords gives a 64bit result
    libpng.pas&#40;1649,47&#41; Warning&#58; Mixing signed expressions and longwords gives a 64bit result
    I can't see any signed expressions there. Maybe the compiler is too dumb to realise that there are none.
    [size=10px]&quot;In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it&#39;s the exact opposite.&quot; -- Paul Dirac[/size]

  10. #30

    PNG library that works on Win32, Linux and MacOS X...

    Thanks for testing it. Good to see that the basics are working.

    If I upload my Siege of Avalon layering demo, could you try and compile and run it under Linux? It works under Win32, but it would be nice to see if the TPngImage class it uses for Load/Save Stream is also cross-platform enough.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

Page 3 of 4 FirstFirst 1234 LastLast

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
  •