Where can I find a resource on how to create a custom image format?

Started by
11 comments, last by hplus0603 18 years, 3 months ago
Quote:Original post by Horatius83
Unless you're developing some wickedly brilliant compression scheme I would have to agree with the above posts, existing formats have most of the major bases covered. In the end you'll either have an index value pointing to a color table for each pixel, or you'll have so many bits dedicated to various color channels per pixel. Even with compression it will stil have to be converted to an array of color values at some point, so I would save my effort for more interesting problems.


I concurr with both this, and the moderator's post, with one exception:
sometimes you've just gotta do things to understand how they work. I know it's easy enough to grab libpng or libgd or what have you, but for some people it's just not enough to read about how something works, but you just have to get your hands on it and know the raw feeling of what it takes to compress an image.

That being said, I used to do a lot of this kind of thing when I was playing around with compression years ago. It can be as simple as indexing color values, to run length encoded images to B&W transforms to fourier transforms; it's a good way of learning all of the various algorithms and mathematical steps of doing it, just don't fool yourself into thinking that they're any better than something that currently exists unless it really really is better (which is highly unlikely) and definitely if you're writing a game or something, don't use it.

So, to recap: unless you just want to experiment with image compression, you've really got no business writing your own image format. It only stresses yourself and others out, and the end result just isn't any better than anything on the market already.
Advertisement
Yeah, I dont intend to make a format to beat all others, it's primarily just for learning.

Anyway, one more question. To store pixels, would I used an array of unsigned chars or unsigned ints? I've been told that using int was better, but I dont see why I would need a value greater then 255, and also ints take more space then chars.
Hey babe.
You can represent a single RGBA pixel as an unsigned int. "0xaarrggbb" will lay out (on x86) as "bb gg rr aa" in memory. It's sometimes faster to do operations by word than by byte, and it's certainly easier to write pixel-indexing code when an index of 1 means "the pixel one pixel in" rather than "the green component of the first pixel".
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement