Is there a perl-ish way to strip the header off a BMP image
and get only the raw image data ?
Unfortunately, there a several variables for BMP files (such as
compressed/non-compressed, different number of bits per pixel), so to
do this correctly you'd have to handle them all.
Are you familiar with *.ppm files (specifically, of type "P6")?
This looks to be just about exactly what you want, where each pixel is
encoded as 24 bits (that is, one byte for RED, one byte for GREEN, and
one byte for BLUE). The only difference is that *.ppm files include a
short header to specify the width, height, and range of intensity
values.
You can read more about this file type here:
http://en.wikipedia.org/wiki/Portable_pixmap
The nice thing about this file format is that several free image
manipulator programs & libraries (such as "ImageMagick", "xv", and
"The Gimp") support this type, so converting an image of a well-known
type to a *.ppm file is very simple.
And writing to this type of file is very simple, as well. Since
there is no compression and just a very short header, all you really
need to know (aside from the width & height of the image) is the RGB
values of each pixel.
As for converting a *.bmp file to a *.ppm file, you'll have to
learn how to read a *.bmp file into an list of pixels, as well as
extract out its width & height. Since there are several variable
things you have to watch out for, it will probably just be better for
you to use a free third-party software tool to convert it to a *.ppm
file for you.
And once you have a *.ppm file, you can just read it in as a binary
file (using Perl if you want), strip off the short header, and you
have exactly what you want!
I hope this helps, Torben.
-- Jean-Luc