I wrote a little program that converts ".simple" images (which are a list of R,G,B bytes) into 24 bit .bmp files. So, your program simply writes a tiny header and three bytes per pixel, and simpletobmp.exe turns this into a .bmp.
Here is an example:
FILE * fout;
fout = fopen("test.simple","wb");
fputc('S', fout);
fputc('2', fout);
fputc('4', fout);
int x,y,width,height;
width = 512; height = 256;
fwrite(&width,sizeof(int), 1, fout);
fwrite(&height,sizeof(int), 1, fout);
for (y=0; y<height; y++)
{
for (x=0; x<width; x++)
{
fputc( y%256 , fout); //Red
fputc( x%256 , fout); //Green
fputc( 0 , fout); //Blue
}
}
fclose(fout);
Or, from Python,
import array
fout = open('pyout.simple', 'wb')
chars = array.array('c') #char
chars.append('S')
chars.append('2')
chars.append('4')
chars.tofile(fout)
WIDTH=512; HEIGHT=256
ints = array.array('l') #signed long
ints.append(WIDTH)
ints.append(HEIGHT)
ints.tofile(fout)
bytes = array.array('B') #unsigned char
for y in range(HEIGHT):
for x in range(WIDTH):
bytes.append(y%256)
bytes.append(x%256)
bytes.append(0)
bytes.tofile(fout)
fout.close()
Now, one can run
simpletobmp.exe o test.simple test.bmpto get the image.
This is similar to how in Linux, one can write a .ppm file, which is, literally, a brief header and list of rgb values. It's funny, the .ppm format can even accept pixel information in human-readable ascii digits!
Download:
Windows binary
Source LGPL license.
Simpletobmp uses the LGPL bmp_io library by John Burkardt.