PocketFrog to only support PNG images? What about STL?
I've put some thinking about this and basically I'd like to drop support for all image format and keep only PNG files.
Here are my main reasons:
1) Only suppoting one format means smaller memory footprint.
2) There is already a really good library to handle PNGs (libpng).
3) PNG files can support anything a game needs (alpha, different color format, palettes, and so on).
4) PNG files use good and loseless compression.
5) libpng uses ZLIB internally, and integrating ZLIB with PF seems a good idea.
STL: lot of people are having trouble with this. Even though a FAQ about it is available, even though I provide the config files needed in the \etc directory, some people are still having a hard time with installing it.
Should STL be dropped in PF? People who know/can use it will do so anyways... I am just wondering how many people have (or don't have) a problem with it.
Thanks for any feedback!
You should also drop png and support only tga and jpeg.
But that's only my point of view...
StephC wrote:You should also drop png and support only tga and jpeg.
But that's only my point of view...
In my mind PNG is far superior to TGA and I am unsure about JPG. Please elaborate on your point of view?
What does TGA gives you that PNG don't?
I use TGA in my stuff too but the only reason is that this format is extremely easy to load/parse and since I bundle all my data in a single zip file (
http://icculus.org/physfs/), I don't care about compression for my image files anyway.
Overall, PNG is superior in just about every regard so I think PNG is the way to go.
warmi wrote:I use TGA is my stuff too but the only reason is that this format is extremely easy to load/parse and since I bundle all my data in a single zip file (
http://icculus.org/physfs/), I don't care about compression for my image files anyway.
Overall, PNG is superior in just about every regard so I think PNG is the way to go.
png IS superior as a file format for one file, I totally agree.
But when you need to pack a lot of files in a single compressed archive (quite a good solution for pocketpc games) you don't want to use a compressed image format (unless it's jpeg).
Tga is so easy to read that you can write your reader in about 2 hours, this reader can make all the needed transformations (rotation/scaling/dithering/tint/RLE) in a single pass when reading the file.
We don't really need a full featured image format to store sprites.
I would support your PNG decision 100%. To paraphrase Bill Gates: "PNG should be enough for anyone!". GIF has some legal baggage attached, as does JPG I think. Even if JPG doesn't, it's a lossy format, and although you can get smaller file sizes in some cases, I don't think it's enough to justify supporting it, EVEN in a limitied memory footprint device. As long as the loader supports as much of PNG's functionality as possible (dictated by libpng for the most part, I know), then I think it's a perfectly good decision.
About the STL thing... I think I had about five minutes problem with it the first time I used PF, but I had exactly zero experience to help, and it STILL only took five minutes to get working. So, it's not a big deal to me to be there.
That being said, unless PF itself really needs it in some way, I would be for removing it. I'm a minimalist 99% of the time, and I prefer as little dependencies as possible in a project. From a simplicity point of view, removing it probably makes things marginally easier and simpler, and simpler is always good in my mind.
I personally have not used STL except for in PF compilation, so I frankly wouldn't miss it. Like you said, anyone that WOULD miss it is going to use it separately anyway.
About your zlib comment... how do you plan to integrate it? Do you mean as part of image loading, or just putting a wrapper API segment into PF so you can use zlib as you want? If the later, I would vote against that frankly, for the same reason I'm OK with taking STL out... less dependencies, a little simpler, and if you need if you'd use it anyway.
I think PNG is fine. Although I suppose some use TGA, so perhaps you should at least add support for that later (or keep support for it if it's already there). I don't see a point for any other format.
I'd drop STL. Reasons being, there seem to be some oddities when trying to use it with various version combinations of both eVC and STL. I'm sure stripping out STL from PF will be a pain for you, but in the long run I beleive it'll make PF more "newbie" friendly, and also make it less problematic on installation. Also, for some strange reason which I cannot comprehend, some people don't like using STL at all.
Just think, by removing it, you'll no longer have to offer support and FAQs for those "dumb" people who can't figure it out.

StephC wrote:Overall, PNG is superior in just about every regard so I think PNG is the way to go.
Then why not use it.
StephC wrote:png IS superior as a file format for one file, I totally agree. But when you need to pack a lot of files in a single compressed archive (quite a good solution for pocketpc games) you don't want to use a compressed image format (unless it's jpeg).
Nothing prevents you from packing multiple images in one PNG and then add that PNG to your archive file. I don't see where the problem lies. JPG loose quality with compression. I don't see how the artists will agree with me butchering their work.
StephC wrote:Tga is so easy to read that you can write your reader in about 2 hours, this reader can make all the needed transformations (rotation/scaling/dithering/tint/RLE) in a single pass when reading the file.
PNG is even faster to integrate, I did it in 20 minutes with PHAL... And it does lot of pixel format conversion to suit your needs. You can even define your own transformation very easily. In any case the point of integration is pretty moot as I will be the one integrating it with PF.
StephC wrote:We don't really need a full featured image format to store sprites.
Maybe not. I am concerned about the extra memory footprint of using both libpng and zlib. If I remember correctly, it is around 150 kb. If you save more then 150 kb on your images using PNG, then it's worth it. Of course loading time might be slower then TGAs.
TGA in my mind is just a raw pixel format used to quickly store images captures by a digital camera or recorder... Not a format you want to keep around.
I've only ever used png in a PPC project, so it sounds good to me. I could see some uses for a lossy format like jpeg.
As for STL, I don't really care that much. It'd probably be better without, simply because people seem to have such a hard time with it. Personally, I hate to see a talented programmer wasting his time replacing STL containers and whatever else).
Thierry wrote:
Maybe not. I am concerned about the extra memory footprint of using both libpng and zlib. If I remember correctly, it is around 150 kb. If you save more then 150 kb on your images using PNG, then it's worth it. Of course loading time might be slower then TGAs.
It's often better to store sprites as paletized images (256 colors), if you store all the image of a game in a single png you may not have enough color in the palette for all the sprites.
About compression ratio, I've found that lz compressed tga files are just as small (and often smaller) than png.
TGA in my mind is just a raw pixel format used to quickly store images captures by a digital camera or recorder... Not a format you want to keep around.
TGA is a very good and versatile non compressed image file format, it was the first to support alpha channel and many color depth, and it's simplicity is it's best feature.
I was using PNG when I started programming uEngine and I have only gained speed by dropping it...
TGA is still a very popular format for shareware game programmers and 2D artists...
StephC wrote:It's often better to store sprites as paletized images (256 colors), if you store all the image of a game in a single png you may not have enough color in the palette for all the sprites.
PNG supports palettized images better then TGA.
StephC wrote:About compression ratio, I've found that lz compressed tga files are just as small (and often smaller) than png.
That would be a good reason to use TGAs. Perhaps PNG isn't good on small images, that would explain your results. Thanks for the info.
StephC wrote:TGA is a very good and versatile non compressed image file format, it was the first to support alpha channel and many color depth, and it's simplicity is it's best feature.
Being first doesn't mean better, but I agree with the simplicity factor.
StephC wrote:I was using PNG when I started programming uEngine and I have only gained speed by dropping it...
It sure would reduce the memory footprint. For my own games I use ZLIB anyways, so the PNG overhead is minimized.
StephC wrote:TGA is still a very popular format for shareware game programmers and 2D artists...
Agreed. So is PNG.
I think we need to understand that stephc has a fetish for optimization and low level ocding, and stephc needs to understand that not all games are as ambitious as Crazy Kart. :-)
PNG should be good enough for most people.
mlepage wrote:PNG should be good enough for most people.
I also think so.
StephC: sorry I messed up with your last post, it wasnt intentional.
Thierry wrote:
StephC: sorry I messed up with your last post, it wasnt intentional.
erf, no pb, I've expressed my point of view anyway.
Might I offer a middle-road option?
Thierry, how feasible do you think it would be to implement something of a "plug-in" architecture for the image loaders? If you define a standard API, and then allow an image loaded to implement that API, there wouldn't be a problem.
You could package a PNG loader in with PF, as I suspect most people would want, and then when StephC gets around to writing a TGA loader, he can contribute it to PF and you can include it in the next release.
And when someone wants GIF support, or JPG support, or <my custom image format here> support, they write a loader and contribute it (if they want to).
I'd bet your code is flexible enough already to support that without too much tweaking know you...
One day I'll come with a benchmark of my sprite loader and you'll all consider dropping png for tga

StephC wrote:One day I'll come with a benchmark of my sprite loader and you'll all consider dropping png for tga :)
I think the current benchmark that Johan wrote is a good start, but ain't what we need. There is no point in benching the same thing (blit) with 3 different images.
The benchmark should measure orthogonal things:
1) Loading time
2) Blit time
3) Flip time
4) ...
Thierry":1wehdnw4]
Agree.
But there is no perfect benchmark...
Blitting 5000 times the same sprite is never done by a game....
StephC wrote:But there is no perfect benchmark...
Blitting 5000 times the same sprite is never done by a game....
That is precisely my point. Benching the time it takes to blit the same image over and over is not that useful. For example, the image happens to always be in the cache, a scenario that is unreallistic.
Out of curiosity, Thierry, how hard would it be to do this:
Rather than stripping the current image loaders, could you wrap them with "#if defined" statements, so if someone wants to use the old GIF/JPG/BMP file formats, they could just "#define _OLD_IMG_FORMATS_", and then the compiler would keep them around.
If that's too much of a chore, just strip the bad boys out.
I'm all for using PNG, especially since we'll finally get AlphaBlitting... Yay!
Keep up the great work.
-John
PS. Any eta yet on 0.8.0?
Presto wrote:Rather than stripping the current image loaders, could you wrap them with "#if defined" statements, so if someone wants to use the old GIF/JPG/BMP file formats, they could just "#define _OLD_IMG_FORMATS_", and then the compiler would keep them around.
I will probably change things in the API. One thing I'd like is to make sure each release if backward compatible. I was thinking about marking some features as "deprecated". The old image loading code could be handled this way. But I havent decided on this yet.
Presto wrote:I'm all for using PNG, especially since we'll finally get AlphaBlitting... Yay!
Yes it's about time. In 0.9 probably. 0.8 will just be a port to PHAL with some cleaning (I'll base it on 0.7.0).
Presto wrote:PS. Any eta yet on 0.8.0?
I hope to get a new release of PHAL and PF done this weekend.
I agree completely on the benchmarks.. The main reason I did the benchmark (comparing GapiDraw 1 and 3 initially) was to see if there were any more features to be done by uncompressed surface-to-surface blitting. Obviously I've been developing too much on my stationary PC lately...
We will have a sprite engine. I doubt it will be as fast as StephC's initially - at first we will not make it in assembler to make it run on all platforms (so we cannot use ldmia). But we will hopefully get there. But the need for a sprite engine has really got into my mind. I believe there still is a need for a surface engine like we have now (especially for stuff not strictly game related), but an RLE engine really kicks ass on mobile devices. Smart move on integrating alpha channels in the RLE stream to save bandwidth!
To put my take on the subject softly, PNG's ROCK!!!.
Ok, now that thats over ill explain myself a bit. First off, I dont think Jpeg should even be an option except maybe for an optimization purpose that I am not aware of. I am a artist and a coder bundled into one, while this gives me a broad view I dont have the super low level experience StephC does.
I do know that I hate the lossyness of Jpgs, especially when it in a game. I cant imagine paying for a game where there was artifacting in the base graphics that I worked so hard on(I expect this in rotation/scaling). My only gripe with PNG's is the built in gamma correction doesnt always work as expected.
PNG's also give you the option to save them as palletized as well as true color. This may account for Stephc's observation that targas are smaller zipped. If you dont palletize a png, it will be a much larger file.
I use to save stuff in targa format, but Png's are just much nicer since they are allready compressed and you dont worry about zipping them up anymore.
Anyhow, thats just my take on the situation.
Sometimes you need jpeg to store very large pictures (not sprites).
jpeg with low compression ratio + dithering is not too bad, and its still 5 times smaller than an equivalent lossless png.
Thierry wrote: For example, the image happens to always be in the cache, a scenario that is unreallistic.
Yes, and the Cache Preload (PLD) instructions that I've put carefully in my assembly is of no use if data are already in the cache...
My vote is for removing STL as well... and I like the idea of PNGs only, but would like to have the other options still sitting there, so have the other
loaders possibly there, but #ifdef'ed out initially...
Great, right after I got all my PNG files transferred over to GIF to use PF...

Birdiestyle wrote:Great, right after I got all my PNG files transferred over to GIF to use PF...:)
PF currently does support PNG (on the device at least).
So it does.... I missed that, and thought I read somewhere the supported file types were only bmp,gif,jpg(and lazy me, I didnt check it out)...
Oh well.... Should have known it was imgdecmp.dll.....
I guess it made my executable a little smaller.. Although I may have to
switch a couple back to sharpen them back up....
I use STL in many places in my game, as I know it is very efficient. I use a lot of arrays with data and I can't imagine how can I use them without STL vectors. I am not experienced proggramer but I hadn't a lot of problems with STL. My question is: If there would be no support for STL in newer version of PocketFrog, could I use it anyway, using something like NO_NEW_IOSTREAMS ... and #include <vector> only.
Or it would be a little bit more complex.
As for PNG and other formats, would it be possible to load some image of PixWidth*PixHeight and it will only take PixWidth*PixHeight*2 bytes in memory(using libpng or whotever) not about PixWidth*PixHeight*6 like with imgdcmpl?
i agree with removing STL. people could always add it if they want it in their project. (it also gave me a headache when i did my first compile)
with PNG thing...
i'd go with the plugin or api or compile time choice, rather than really be forced to use one format. this might alienate some people already comfortable with other formats; other formats might also have some features not present it others; and first time users of the library or amateur programmers might go ... "what? where's the bitmap loader" :)
PNG should be the main format, no doubt about it
we could have another lib just to lod tga,jpg,gif... and things like that
I like to use jpg´s for backgrounds ( big images ), using low compression, the result is good and the size is smaller than any lossless compression.
but I support the main use of only png files, the others should be a external option
I use jpg for most of the image resources in the 2d side of Space Treker with a few BMPs where I need to rely on the color for transparancy to work. While I'm happy to work in png in future I don't want to contemplate re-saving & importing all these resources.
ps: The last main function (tactical) is progressing well leaving sound, load & save game to implement. Weapons with bullets proved easier than missiles but I've got both types working.
So I get the overall impression that PNG is a good thing and that JPG should be kept (useful for large images). I guess it makes sense.
A pluggable image loader architecture makes even more sense. Hint-Hint

Not sure where I heard this before though...

Maintening the pluggable architecture is the problem =)
I guess I could have a config.h file where you select what you want. Something like:
#define ENABLE_JPG
#define ENABLE_PNG
#define ENABLE_IMGDECMP
#define ENABLE_SUPER_FAST_BLIT_THAT_WORKS_ON_2_PIXELS_AT_ONCE_TM
And so on...
Thierry wrote:So I get the overall impression that PNG is a good thing and that JPG should be kept (useful for large images). I guess it makes sense.
perfect, the best of both worlds
I have some patent questions about Alpha Channels in TGA,PNG and completely TGA format.
1. I know that PNG format is free. But what about using alpha channel in it (PNG) and TGA? Apple has patent for using alpha channel. Is it patent free to save and then use alpha channel in those formats?
2. Is TGA format patent free. Can I use it in my commercial products (free)?
There is no patent related to PNG. The format was created by people fed up with GIF's patent. I am pretty sure there is no "alpha blending" patent.
I don't know about TGA, but I would be surprised if there was any patent on it. Without compression, it's just a binary dump of an image.
Thierry wrote:There is no patent related to PNG. The format was created by people fed up with GIF's patent. I am pretty sure there is no "alpha blending" patent.
Read here:
http://www.libpng.org/pub/png/pngfaq.html#patents
However, the fact that is possible to implement PNG without infringing any known patents certainly does not imply that it is impossible to implement it in a manner that does infringe one or more patents. Patents are a minefield, and several are known to be closely related to PNG technologies:
Stac (Waterworth, 4,701,745; Whiting et al., 5,016,009), LZ77 with hashing: deflate algorithm
PKWARE (Katz, 5,051,745), LZ77 sorted hash: deflate algorithm
Apple (Othmer & Leak, 5,379,129), alpha mask images: alpha blending
Thierry wrote:
I don't know about TGA, but I would be surprised if there was any patent on it. Without compression, it's just a binary dump of an image.
I also think so. But may be StephC (well known TGA user) or any others can clear the situation?
Maxim wrote:
I also think so. But may be StephC (well known TGA user) or any others can clear the situation?
Well...
I think it's highly improbable that I'll be one day in trouble because of any patent infringement on TGA or alpha channel (sic).
And if it was the case, it will be very easy to write a converter from .tga to .stephc which is a 100% proprietary format (my own little binary dump).
I think that companies like Apple and PKWare have other things to do then sue the author of a graphic library for Pocket PC games.
The day I make millions of dollars out of PocketFrog, I will consider paying a layer to look into these things.
"Layers" don't cost that much. You can get a hand job for $20. Not that *I'D* know. Ahem.
(Sorry Thierry... it's late over here, I had to make the pitiful joke at the expense of your typo).
Hi Thierry,
I would like to see at least PNG and JPEG. Each has a very differant purpose. PNG is fantastic when you need your decompressed image to be identical to the original, for example a color is selected for your transparency. If you were to use a lossy compression then this "transparency color" will be mangled, but in the lossless it will still be the same decompressed. Alternatively, in many cases there is a great need to have a file where a loss in image quality is worth sacficing when one needs a really small file size, therefore using a JPEG would be ideal in this case. PNG's are great for continous tone color and JPEG do extremely well with natural images.
As for grouping images together, that is a moot point. It really isn't any work at all to create a file that has all the images in sequence, infact you could even mix and match what ever format you want!. I do just this. I have a file that contains bot PNG and JPEGs all in what ever order that I need.
Anyways, in summary all I want to say is that one would be able to accomodate the largest collection of images by supporting both lossy and losseless images through PNG and JPEG formats.
Cheers,
Clint
I would personally prefer GIF over JPEG.
wyrd wrote:I would personally prefer GIF over JPEG.
Can I ask why?
Personally, provided I have one lossy and one lossless format (eg, JPEG and PNG respectively), I don't need anything else. Any additional compression could be done with zlib.
wyrd wrote:I would personally prefer GIF over JPEG.
GIF and JPEG are unrelated. One is lossless and the other is not.
GIF has patent issues, and you can't use it without paying royalties. The only reason we get away with this on Windows and PPC is because we use Microsoft's GIF reader and they are paying for the royalties.
If PocketFrog is to become multi-platform, then GIF has to be thrown out the door.
Not everywhere in the world... We have to wait another year.
In any case, PNG is way better (many formats) and provides better compression.
Oh, well in that case, GIF is a bad idea.
