Archived

This topic is now archived and is closed to further replies.

TWild

Photoshop's bmp

Recommended Posts

Whenever I try to load an image saved in photoshop (8-bit, indexed color) my program crashes. It does fine if I save with PaintShop Pro 7 (demo). I should be able to do this with photoshop, but can''t figure it out. Any ideas?

Share this post


Link to post
Share on other sites
Also, I''ve noticed other programs (like IView) creates a "BM6" header, even if the BMP is 24-bit. Photoshop seems to create a "BM8" header for the same thing (dunno if it adds extra stuff in there, but my converter worked fine when I added BM8 detection.)

2DNow - Specializing in yesterday''s technology today!

Share this post


Link to post
Share on other sites
Well, I''m just starting out :/ I''m using Andre Lamothe''s libraries from Tricks of the Windows Game Programming Gurus, 2nd ed. I finally got a bitmap to the screen! Next step, multiple bitmaps to the screen.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A bitmap contains 2 ways to save the height/width information of the bitmap image.


  
typedef struct tagBITMAPINFOHEADER{ // bmih

DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;


The above is a bitmap header definition. Most packages fill out this structure completely. However photoshop does not. If I remember correctly it uses the biXpelsPerMeter and biypelsPerMeter to calculate the biSize of the image. IE, it doesn''t store the biSize of the image in the structure as it should. Now most bitmap readers out there take for granted that the biSize is there and is valid (Aka lamothes BMP reading code), and it uses this to determine how much of the bitmap to read. You can see this can be a minor problem. Your best solution to this problem is to make some modifications to the file loading code that fills in the structure completely based on the data photoshop saved that is valid.

Share this post


Link to post
Share on other sites
The problem with Photoshop''s bmps is that it will always have the biSizeImage to 0. In order to counter this insert this code before you allocate the memmory for the bitmap (before you use the biSizeImage).

  
// Check to make sure that the biSizeImage isn''t empty (which it is if it''s a Photoshop bitmap)

if(bitmapInfoHeader.biSizeImage == 0) {
bitmapInfoHeader.biSizeImage = (int)bitmapInfoHeader.biWidth * bitmapInfoHeader.biHeight * (bitmapInfoHeader.biBitCount / 8);
}

Share this post


Link to post
Share on other sites