Alternatives to .TGA
Lachlan87I've been using .tga's for my game, basically for no reason except that they were smaller than .bmp's and had alpha channels. Recently I took a look at how big my graphics folder was and just about choked. Over 40MB and I'm still just starting!!! Can anyone recommend a better format for games? I need an Alpha Channel and 16 bit color. If possible, I would prefer a format that DirectX 9 can load for me, but that is not a requirement.
Eric ColemanYou could store your graphics in a compressed archive, and then just extract them when you need to load them in your game. You could also use .png files, which can store alpha information. Do a search on google for libpng. Png files are just regular bmp data compressed with zlib. You could try to create your own format using bzip2, which is free and better at compressing. Go to the Links page and look in the Tools/Libraries/Engines category for the links to both zlib and bzip2 homepages.
VBBRI recommend PNGs also because they are small and free. Also for what Eric said it uses lossless compression, which preserves the image quality. (I'm in luck here because Revolution3D already loads PNGs for me... [:D]) Also I use BMPs in the development stage because they are easier to edit (MS Paint) and then convert them all to PNGs for final distribution.
Sr. GuapoDefinately go with PNGs. They are tiny compared with bitmaps and they retain all the image quality. Almost all the major photo editing software supports them (PaintShop, PhotoShop, etc.). D3DX 8 can also load them easily in the CreateTextureFromFileEx call. It is really a great little format...[:D]
Lachlan87Wowza! Pngs are tiny! Thanks guys, thats even better than I had hoped!
masterboodaWow! No kidding I just changed all my .bmps to .png's on a massive game I was working on and saved about 20mbs of room.... That is a great format... why I never thought of it before is beyond me, but I didn't think dx8 supported them... One question though, can anybody point me to information on extrapulating the alpha channel, that way I can get rid of .dds files too, because they are huge... DaBooda out...
Almar JolingWhy don't you use TGA's compress feature? OR change the bitdepth lower if needed. I only need 24/32bit for 3 of my 15 textures, the rest is 16 bit with alpha channel. TGa without compression zipped is still bigger than TGA with compression compressed as ZIP, I checked it out last week for my own stuff :)
VBBRAre TGAs royalty-free?
Sr. GuapoAs far as I know... [:)]
VBBRGreat [:D]
Sr. GuapoHere is a quick comparison. I made a huge (1024X768) image and saved it in all the common image formats. Here are the sizes: BMP: 2305 KB PNG: 50 KB GIF: 30 KB* JPG: 179 KB TGA: 150 KB * A gif only holds 8 bits (256 colors) per pixel, and I do not(though I am not sure) think it holds alpha information, though this can be determined using the ColorKey value in LoadPictureFromFileEX. Using that comparison, I think everybody should use gif, if possible, or PNGs. There is no comparison.
Eric ColemanI think .TGA files use Huffman encoding, which is part of the .GIF compression scheme, and that means they fall under the same patent. Someone may want to verify it just to be sure. Also, png files can store an alpha channel. I don't know if Directx8 will load the alpha data.
Sr. GuapoThis is just what I found out in 5 minutes using PSP 7, so I may have messed something up...
VBBRBut don't forget Eric, that the GIF patent expired last year (I guess you should know it)... so would it be OK to use TGAs (assuming it falls under the same patent)?
Sr. GuapoIt is fine to use them, I think, even with the patent, as long as you don't create the same compression algorithm for your own file... I may be wrong, however... The patent just stops everyone from copying the idea and distributing their own version
Almar JolingTGA is supported in DirectX8, so it's not our problem I think :). Anyway, was the TGA file in it's compressed form? :). and GIF is 256 colors, which won't work out most of the time, JPG should NEVED be used for colorkeyed stuff. And there was something with PNG as well.. :)
Sr. GuapoJPGs compression is very bad if you want colorkey values. Some of the colors will be blended, and the texture will look very strange... About the compression... I have no idea, that is what happened when I "save as..." in PSP. I don't have the TGA compression software/algorithm, so I don't know how to compress it...
masterboodaI was wondering about .png alpha channels, because in paintshop you can use a mask to create the alpha channel into the .png, and it becomes part of the image. Anybody who has worked with macromedia flash, will know that you can use .png's and they will be displayed with the alpha channel. So I am wondering if there is a way to create, lets say a .dds image on the fly, by bringing out the alpha channel in directx8. This way all the images you will need will be .png files. DaBooda out..
Sr. GuapoI have a question... What is a .dds file? I realize it is an image file, but I cannot find a program that supports it (PSP, photo editor, MS Paint, etc.). I am confused, and I am sorry if this sounds very "noobish"... [:)]
masterboodaA .dds file can only, as far as I know be made with the dxtex tool, that comes with the directx 8 sdk.... It takes two bitmaps, one of the image, then one of the alpha, which is a grayscale image, with white being solid and black being transparent, and the values in between being variations of the in between... It is a nice little format, because you can have textures in your program with variable alpha... and you can also ignore color keying and all that, it is what I like to use, but like I mentioned earlier, the size is just a little bigger than a bitmap, so they take up quite a bit of room... so if I have two png's representing one image, maybe I can create the alpha channel on the fly from two images, because 2 png's are even smaller than .dds.... DaBooda out..
Sr. GuapoOK, that makes sense... Anyway, are you going to try and make your own parser, or just loop through with getPixel (or something). Either way, it will take a while for large images, but as long as you are not running them during the game loop...
masterboodaI figured I would have a set up program, that will convert all the images and save them to a folder, this way it will be a one time deal. And they can then run the game using those images. Also the set up will delete the png's. With this method, the export size of the game will not be that large, but the program set up on hard drive will be large. DaBooda out
Sr. GuapoI would like to point out that .pngs are only compressed (zipped) 5% of more than they are normally, meaning they are very compact... compare that with a .bmp - 96%!!!
Almar Jolingin PSP7 you have something like "Options" when saving TGA.. :) btw: Try compress a BMP, I thought it will be quite the same as PNG.
Sr. GuapoInteresting... I zipped both a 32X32 .png and a 32X32 .bmp... originally, the bitmap was 3126 bytes, and the PNG was 313 bytes. After zipping, the PNG was 309 bytes, and the bitmap was 129 bytes! Yes, those numbers are correct... It seems a bitmap is alot smaller once compressed by winzip than a PNG...
VBBRBut which is faster to load, a PNG or a BMP (decompressed on-the-fly) ?
Sr. Guapofind out... [;)] Use QueryPerformanceCounter and have fun. There is a good tutorial on using it [url=""]here[/url]. It is really easy. I'm just too lazy during summer vacation... [:D]