Re: working with bitmaps in C




"Ernie Wright" <erniew@xxxxxxxxxxx> wrote in message

Broken for 24-bit and 32-bit, and for 4-bit old-style. See below.

No, it's been tested and basically works. It might not work on everything, but it will load the vast majority of BMPs OK.

This description is inadequate for an API function. What loadbmp()
returns is a 24-bit bitmap written as an array of 3-byte pixels in BGR
order, with row span of 3 * width, and origin in the upper left corner
of the image. Callers need this level of detail in order to know how
to use what loadbmp() returns.

No, in rgb order. As is the palette. However that proves your point that the comment is inadequate. Most of the bug reports are based on that misunderstanding.
The exception is passing a 256 palette size here.

/* 4 bit bitmaps */
if(bmpheader.core)
loadpalettecore(fp, pal, 256);
else
loadpalette(fp, pal, bmpheader.palsize);

I think there's some problem with old BMPs which have core rather than proper palette sizes. It's a while since I wrote that code, it might have been that I had a degenerate BMP as the test case . Maybe you need to calculate the palette size from the raster offset, if you can trust it.

Thanks for taking the time to comment, however.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

.



Relevant Pages

  • Re: working with bitmaps in C
    ... but it will load the vast majority of BMPs OK. ... The exception is passing a 256 palette size here. ... I think there's some problem with old BMPs which have core rather than ... in I know are 8bit images and are 1280x960. ...
    (comp.lang.c)
  • Re: Please Help! Dynamic loading of the bmp files in the appl
    ... > Today I have *.exe file of the appl for each language. ... > According to bmps for german language, I want to have all bmps in one ... > Is it possible when I load the appl to load some general bmps to the ...
    (microsoft.public.vc.language)
  • Please Help! Dynamic loading of the bmp files in the appl
    ... Today I have *.exe file of the appl for each language. ... According to bmps for german language, I want to have all bmps in one file. ... Is it possible when I load the appl to load some general bmps to the memory ...
    (microsoft.public.vc.language)
  • Photoshop 7.0 does not open JPG files anymore
    ... photoshop suddenly fails to load any JPG files (BMPs seem to load OK). ... No matter whether via Open Dialog or by drag'n'drop, if I open a JPG, nothing happens. ...
    (alt.graphics.photoshop)