Image formats?

Blitz3D Forums/Blitz3D Programming/Image formats?

xmlspy(Posted 2004) [#1]
OK, I want to know the differences between the image types(bmp, jpg, png, etc) that Blitz3D can handle, why should I pick one instead of the other?, and what is the best for game textures. Another question: should I use 256x256 or 512x512 images for terrains(height, color, and detail maps)


MSW(Posted 2004) [#2]
www.wotsit.org

Will give you a LOT of info on file formats includeing some overview as to the pros and cons of the file format...

Basicly a JPG uses a compression format that allows small file sizes at the loss of image detail (depending on how much you try to compress the image...and the specific image in question, basicly the areas with sharp contrast will show compression artifacts the most)...this is great for image storage, and download times...but the loss is in the image quality...once the image is loaded into Blitz however the reduced memory footprint no longer applies...so that 512 by 512 32-bit color image contained in your 100k or less JPG file takes up a megabyte once loaded.

BMPs are pretty much what you see is what you get...file sizes are large, huge even (can be reduced by changeing the color depth however)...so they are a pain to download...but as long as the BMP color depth is at least 16-bit, you can fairly accuritely and quickly guage how much memory the image will take up once loaded in.

PNGs are a bit like both...more or less sorta the "next generation" of the old GIF image file standard (not to be confused with animated GIFs)...the format allows lossless compression (unlike JPGs) but typicaly it can't compress nearly as much because of this...the big perk is that this format allows the inclusion of the alpha channel for transparency effects...

A lot is going to depend on the image itself...specificly the color depth, and what sort of image loss you are willing to except...not to mention what the image is intended to be used for...

generaly it's recommended to stay away from BMPs...however they do have thier uses...for example say you have a little red crosshair for use in a FPS type game...the image is only 32 by 32 pixels, pure black except for the pure red/orange color of the crosshair shape itself...in Blitz (at 32-bit color depth) that image, no matter the source file type or size, is going to require 4k (32 by 32 at 32-bit color)...however if you were to apply it in game to a orange/red entity colored quad...convert the original image into pure black and white (change the orange-red color to white) and convert it to 1-bit B&W color BMP the resulting file size would be just over 1k with no image loss from compression (you can then texture it on the orange-red entity with the MULTIPLY flag, then render it with the ADD flag to get the same basic effect, with the added ability to change the crosshair color ingame without needing additional texture graphics)...course you could do the same with the other file formats, but for such a small image (and because neither of them support 1-bit color) they arn't realisticly going to be able to compress the image any smaller.


xmlspy(Posted 2004) [#3]
Thanks, very useful.


jhocking(Posted 2004) [#4]
For just about any purpose I recommend PNG. I do occasionally use the other file formats (JPG or BMP for solid images, TGA for alpha transparency) but only because converting images to PNG is occasionally a hassle (thank you Photoshop.)

As for image size, use the smallest that looks good enough. Sorry there isn't a better answer really. It's all judgement calls. I would personally recommend higher res (like 512) for the heightmap image because you want more resolution there, the color map is a total judgement call so try both, and lower res (256 or even 128) for the detail map because it will be tiled.