New version of PNG library (now v3.2.q)

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

Post by yetifoot »

It should work fine in DOS, you don't need a full DJGPP for compiling it, you just need GNU Make, IIRC that is a seperate download on the DJGPP site, so you don't have to get the whole thing. You would also need a static version of zlib for DOS, i assume that is available somewhere on the web. Other than those, I don't see any reason why it would not work under DOS.
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Post by notthecheatr »

Hey, I can't exactly understand this. Am I supposed to compile it into a DLL or can I just include it? I get an error when I try to compile the examples. I tried using makeall but make complained there was "nothing to make."
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

Post by yetifoot »

notthecheatr wrote:Hey, I can't exactly understand this. Am I supposed to compile it into a DLL or can I just include it? I get an error when I try to compile the examples. I tried using makeall but make complained there was "nothing to make."
Well, you could make a DLL if you wanted, but the main way it's set up to compile is as a static library.

I'm not sure what the problem with 'make all' was for you, I just tested it out from a clean download and it worked fine here.

Did you read the doc/readme.txt ?

you can use one of the prebuilt versions under build/ if you can't compile yourself.
Once compiled you will need two files, 'build/libfbpng.a' and 'inc/fbpng.bi'. These
should be placed either in your projects directory, or in the lib/ and inc/ dirs of your
FreeBASIC installation, along with the other libary and header files.

So for a simple usage you would just copy the build/prebuilt/<system>/libfbpng.a and inc/fbpng.bi to your projects directory, then in your program do #include "fbpng.bi" and #inclib "fbpng" and you should be able to start using it.
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Post by notthecheatr »

Thanks, I figured out how to do it looking at other forum posts. I think I had some files in the wrong place.

Great library, by the way, it's just what I need!
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

Post by yetifoot »

*BUMP* New version, see first post for information.
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Post by notthecheatr »

Bravo, this coincides with my writing an image-loading library... well most of the code for loading images is dependent upon other libraries (for example the PNG loading code is dependent upon fbpng) but it makes a consistent interface for loading any format supported.

I'm glad to see fbpng is not dead, this really should be added to the archive too.
lassar
Posts: 306
Joined: Jan 17, 2006 1:35

Could you compile a static library for DOS ?

Post by lassar »

I found a static library for windows and linux but no dos.

Could you compile a static library for DOS ?

I would appreciate it.
sir_mud
Posts: 1401
Joined: Jul 29, 2006 3:00
Location: US
Contact:

Post by sir_mud »

if you have freebasic you can simply compile your own static lib with these commands:

Code: Select all

fbc -c src\*.bas
fbc -lib -x fbpng src\*.o
you will need zlib compiled for dos also (should be able to find a download link on this forum)
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Post by KristopherWindsor »

I'll probably be using this library for my latest program. :-D

I've uploaded the simplest / smallest working FBPNG package / example, which uses this code to load a PNG image:

Code: Select all

#include once "fbgfx.bi"
#include once "png_image.bi"

Dim As fb.image Ptr g

Screenres 800, 600, 32

g = png_load("torus.png", PNG_TARGET_FBNEW)

Put (0, 0), g, Pset

Print g -> Width
Print g -> height

imagedestroy(g)

Sleep
http://freefile.kristopherw.us/uploads/ ... g-test.zip

So hopefully this will help people get started quickly using this lib. :-)

BTW, you can add error checking to the example; if g = 0 then it has not loaded. ;-)
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

Post by yetifoot »

I just had a report from nkk that many tests are failing when using the new 0.20.0 release.

After investigating, I have found that there is no problem with fbpng, just the test BMPs due to changes in the way BLOAD works.

You can read about that change here. (posts by DrV most informative)

http://freebasic.net/forum/viewtopic.php?t=11986

It appears that the change was reverted, so I probably won't change the tests at this point (next release I may look at this), but just let you know that fails in the tests is normal for the official 0.20.0 release, and it doesn't effect your use of PNG in any way.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

Thinking back to the default target type issue, I'm thinking now that the best solution would be to have something dialect-dependent as the default:

Code: Select all

enum png_target_e
	PNG_TARGET_BAD
	PNG_TARGET_FBOLD
	PNG_TARGET_FBNEW
	PNG_TARGET_OPENGL
#if __FB_LANG__ = "fb"
	PNG_TARGET_LANG_DEFAULT = PNG_TARGET_FBNEW
#else
	PNG_TARGET_LANG_DEFAULT = PNG_TARGET_FBOLD
#endif
end enum
That should help compatibility for people who use lang fb and still want to rely on the image having the new-style header structure.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

I noticed some recent changes in SVN to how images are created/destroyed... Does any of it affect your code?
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

Post by yetifoot »

counting_pine wrote:I noticed some recent changes in SVN to how images are created/destroyed... Does any of it affect your code?
No, because I allocate/destroy the buffers with malloc/free in fbpng, it won't effect it.

The only time those changes might burn someone as far as I can tell is if they mix the wrong functions, like callocate/imagedestroy, or imagecreate/free.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

True, but if I didn't know better when using this library I'd choose imagedestroy by default, based on the fact that the function returns an FB-compatible image.

It's something to be wary of, with changes like this...
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Post by KristopherWindsor »

counting_pine wrote:True, but if I didn't know better when using this library I'd choose imagedestroy by default, based on the fact that the function returns an FB-compatible image.
I did that in the example I posted above, and in my program, and have seen no errors. That was in .18.4, and I haven't tested much since installing .20.
Post Reply