Photoshop's bmp
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?
AFAIK, PSP doesn''t do RLE, so that could be your issue. If there isn''t an option to save an uncompressed BMP in PS, Adobe should be collectively castrated.
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!
2DNow - Specializing in yesterday''s technology today!
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.
A bitmap contains 2 ways to save the height/width information of the bitmap image.
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.
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.
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);}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement