Photoshop's bmp

Started by
7 comments, last by TWild 21 years, 6 months ago
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?
---------------------My specs (because I always forget to post them)Intel P4 2.4 GHz640 MB system memoryRadeon 9700 PROWindows XPDirectX 9DirectX 8.1 SDK
Advertisement
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.

[twitter]warrenm[/twitter]

Doh! Thanks for the swift reply
---------------------My specs (because I always forget to post them)Intel P4 2.4 GHz640 MB system memoryRadeon 9700 PROWindows XPDirectX 9DirectX 8.1 SDK
Sure. Hope that helped...it was just a hunch.

[twitter]warrenm[/twitter]

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!
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.
---------------------My specs (because I always forget to post them)Intel P4 2.4 GHz640 MB system memoryRadeon 9700 PROWindows XPDirectX 9DirectX 8.1 SDK
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.
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);}  
Thanks for the info guys (Joe / Spearhawk)

[twitter]warrenm[/twitter]

This topic is closed to new replies.

Advertisement