Which file format for graphics?

Blitz3D Forums/Blitz3D Beginners Area/Which file format for graphics?

Hansie(Posted 2003) [#1]
all,

1) Blitz supports PNG and BMP right? how about JPG or TIFF?
2) Which is the better format and why? in what conditions?

on the side
Any tips on turning a bitmap font into DATA statements so I can include a bitmap font directly in my code?


soja(Posted 2003) [#2]
Yes, Blitz supports PNG, BMP, and JPG. I'm not sure about TIF -- I don't think so.

PNG: Lossless compression. Great for 2D graphics and such.
BMP: Lossless format, but large file size. A lot of support built into Windows for it.
JPG: Lossy compression. Great for shrinking photos to a manageable size (with rasonable quality), but not so great for shrinking pictures with portions of high contrast, like line drawings, text, a lot of 2D art, etc. Only good for a "final" draft -- the picture loses quality every time it gets "jpeg-ified".
TIF: Lossless, usually uncompressed, but can be compressed with certain algorithms like LZH. A great format for keeping detailed originals, but huge files.

One the side:
Yes, you might check out "Pic-2-Data" code in the BlitzPlus section of the code archives. I haven't tried it, but it seems to be what you're looking for. Incidentally, once you embed a picture into your source code, it usually creates a much larger filesize than what you would have had. You'll probably want to use UPX to make it smaller.


Hansie(Posted 2003) [#3]
Excellent Soja!

to re-cap, for a 2D game only, PNG is the way to go?

As for Pic-2-data I need to check it out. sorry to sound silly, but what is "UPX"?


EOF(Posted 2003) [#4]
Also *.tga format


Hansie(Posted 2003) [#5]
whats the advantage/disadvantage of .tga?


soja(Posted 2003) [#6]
Yeah, I'd say in general, PNG is the way to go for 2D games (unless you're using a photo, then JPG perhaps).

UPX is an executable file cruncher. It packs your executables to about half their original size, adds its own header on there that executes, unpacks & runs the program when you run the compressed version. It's very fast too. In short, use it to half your final EXE size, almost for free! The OS doesn't even know the difference.

upx.sourceforge.com, I think.


Hansie(Posted 2003) [#7]
SUPER support Soja

I owe you one


jhocking(Posted 2003) [#8]
The advantage of tga is the alpha channel (which is irrelevant for 2D games.) The disadvantage is large file size since it is not compressed.

Note that PNG also supports alpha transparency but is a pain to work with and that feature is poorly supported in tools like Photoshop. In general, if you need alpha transparency your best bet is to use TGA while working and save final versions as PNG for use in your game.


soja(Posted 2003) [#9]
SUPER support Soja

I owe you one

No problem... I'm sure anybody else would have said the same things had they been online at the same time as I.


Hansie(Posted 2003) [#10]
thanks to everyone


MSW(Posted 2003) [#11]
Another thing you can do is to create your own graphics file format..and use createimage()/createtexture() with writepixelfast() to internaly generate the graphics in Blitz...

Not only would this work for your own file formats...but with other currently unsupported file formats too (www.wotsit.org describes tons of file formats , graphics, 3D models, sounds, etc)...But it's not exactly beginner level stuff.


Clyde(Posted 2004) [#12]
.PNG is what I use nowadays too, as for one thing it makes downloads considerably smaller. But Blitz converts them into BMP's (bitmaps) if Im not mistaken?


Jeppe Nielsen(Posted 2004) [#13]
All image formats are "converted" to bmps, as the images are uncompressed when used/in memory.


Mustang(Posted 2004) [#14]
I like .TGAs, mainly for the alpha channel. I want max quality too, and .TGAs are good for that. You can't edit your textures many times and they do not degrade like if you would edit .JPGs many times (which of course you should not do, but keep .PSD and save that out as .JPG, but ppl tend to be lazy...). What HD space they take is to me irrelevant... anything under 100 megs (whole game) is OK :)


Rob Farley(Posted 2004) [#15]
PNGs have an alpha channel too, I use it all the time.


Mental Image(Posted 2004) [#16]
Through bitter and hard won experience lately, I would say avoid JPG for games in Blitz (for sprites) for one very simple reason - as has previously pointed out, JPG is a lossy compression and what you see is not necesarilly what you get.

Let's say that you have an enemy sprite which has a purple background that you will later mask. With a JPG graphic, look closely at the purple background and you will see that there are artifacts introduced by the compression routines that you mask will not make transparent!

PNG is your friend (that said, I do use JPGs when I am not bothered about masking!)


Mustang(Posted 2004) [#17]
I hate PNGs.


Anthony Flack(Posted 2004) [#18]
Yes, Mental Image - never never never use jpgs with masks! However I do use jpg for my graphics, with an alpha channel stored in a seperate file and combined at run time. The reason is that you can get the files really small and I want my whole game to come in at <10Mb. Although my graphics are photographic; if they were cartoony an indexed palette would give you the smallest file size.


jfk EO-11110(Posted 2004) [#19]
Blitz can load Images even if their Extension is wrong. so when a JPG is named BMP Blitz will nonetheless load it correctly. I use this feature to optimize the Project size before I release things. I pick the huge BMPs and save them as reasonably compressed JPGs, rename them to BMPs. With a lossy compression quality of 10 I usually have pretty small filesizes and almost no visual loss. especially for 512*512 Textures which are mippapped anyway (eg. on Characters) this makes sense. But you should first compare the filesize of a zipped BMP, sometimes this is even smaller than the JPG!

I agree: never ever use JPG for masks, and avoid it for Alpha-transparency. 32Bit TGAs cannot be replaced by JPGs anyway...


Clyde(Posted 2004) [#20]
Can you control all the information of the different image formats with blitz? Or do they get lost in the conversion?


Warren(Posted 2004) [#21]
I hate PNGs.

Because they take up so little space on the hard drive or because they use loss less compression? Which aspect irritates you the most? :)


Agamer(Posted 2004) [#22]
ummm both