![]() |
|
Allegro can't load my bitmaps. Need help with bitmap file format. |
Mr. Xboxor
Member #3,763
August 2003
![]() |
I'm making an 8bit color game, and, as such, have spent alot of time creating a personlized palette and a method of my bitmap images all using that same palette. Here's where I stand: I have programs that will convert any 24bit bitmap into an 8bit bitmap which only uses my personalized palette. I also have drawn a color bar (saved as a 24bit bitmap) so that others may use paint's color selection tool to select from colors that are in my palette. This basically allows me to create 8bit bitmap images which only use my palette colors. 2 bytes: bm signature That's it. One theory that I have is that the offset from header to image also includes the size of the palette. This would explain why allegro is treating the palette as part of the image, because it thinks that the image starts there. Also, when I load an 8bit bitmap and use it's palette, the palette is messed up. This is only with my 8bit bitmaps. So I think the key to this problem is the location of the palette. Can anyone help out? Thanks for your time. "Java is high performance. By high performance we mean adequate. By adequate we mean slow." -Mr. Bunny |
23yrold3yrold
Member #1,134
March 2001
![]() |
Quote: 4 bytes: byte offset from header to start of image Not according to my information ... let's see your code for saving an 8bpp bitmap. Might save some time. -- |
Mr. Xboxor
Member #3,763
August 2003
![]() |
Okay, thanks for your help. I'm gonna show part of my code, because some parts are irrelevant and a mess. But rest assure they have no effect on saving a bitmap. Here's my combined header (meaning I put the file header an info header into one big thing) struct bmpHeaderType For saving a 24bit bitmap to an 8bit one:
Hope this helps. Although, I don't think it is necessary to actually see my code, but you never know. You see, paint understands my bmp file, but allegro and explorer image preview do not. So what assumption do these make that paint doesn't? "Java is high performance. By high performance we mean adequate. By adequate we mean slow." -Mr. Bunny |
23yrold3yrold
Member #1,134
March 2001
![]() |
Quote: So what assumption do these make that paint doesn't? Well, if it's your file header that's wrong, maybe Explorer and Allegro are using that, and Paint just ignores it and reads in that data as it comes across it (entirely possible; you don't need the offset to the pixel data to read it in properly). -- |
Mr. Xboxor
Member #3,763
August 2003
![]() |
Nevermind, I fix it. Like you said, it was my an incorrectness in my bitmap header, so I'll give you credit for that. It was a combination of things. To solve my problem, I converted a correct 8bit image to integer values for each byte, so I could compare it with my own 8 bit image of the incorrect type. Problems with my methods: So everything works just fine now. Thanks for your help 23. "Java is high performance. By high performance we mean adequate. By adequate we mean slow." -Mr. Bunny |
Evert
Member #794
November 2000
![]() |
Quote: So, for some reason, is there another bitmap file format or something.
I know the problem is solved, but as a random bit of trivia, I'd like to mention that there are indeed two different types of bmp file: Windows and OS/2 style. |
spellcaster
Member #1,493
September 2001
![]() |
The OS2 version also stores the lines top-down instead of bottom-up. -- |
Irrelevant
Member #2,382
May 2002
![]() |
OS/2 format seems much better to me... IMO, all you need is:
...not all that garb you had there. Oh well, trust Micro$isth to make everything it touches bloated and hard to use. <code>//----------------//</code>Here be l33tsp33x0rz. |
Korval
Member #1,538
September 2001
![]() |
Quote: Oh well, trust Micro$isth to make everything it touches bloated and hard to use. Yeah. God forbid that they build in the possibility for expansion of the format, or, at the very least, user-defined data. |
Mr. Xboxor
Member #3,763
August 2003
![]() |
I'm going to have to agree. Microsoft's bmp format is very expansive. I mean, Microsoft was clearly looking forward to the future when they allowed the format to stored pictures with 65535 planes in 65535 bit color. And you though 32bit color was enough? On a more serious note, I'm having some problems with 24bit bitmaps. I fixed my earlier problem, but this is for some weird reason. This one picture, and allegro logo, actually, always screws up when I try to convert it to use my colors. So, I deleted the entire picture, so it was just white, and it still messed up. Yet, when I created a new bmp the same size and all white, it worked just fine. Oh well, I guess I just won't use that logo. Even when I pasted it into another file, it screwed up the new file, which worked fine until I placed the logo in it. Does this mean Allegro sucks so much that it screws stuff up? "Java is high performance. By high performance we mean adequate. By adequate we mean slow." -Mr. Bunny |
spellcaster
Member #1,493
September 2001
![]() |
Quote: Does this mean Allegro sucks so much that it screws stuff up?
Almost. That means that the problem is sitting in front of the computer you're using. EDIT: -- |
Mr. Xboxor
Member #3,763
August 2003
![]() |
Umm, okay. I just find it odd how the picture of allegro is messing up any file I put it in, even when I delete the picture from the file afterwards. Oh well. "Java is high performance. By high performance we mean adequate. By adequate we mean slow." -Mr. Bunny |
spellcaster
Member #1,493
September 2001
![]() |
That's part of the voodoo magic. Just because I'm curious... let's assume that you run that program, passing the path to the image as a parameter... is it still messed up?
-- |
Mr. Xboxor
Member #3,763
August 2003
![]() |
Sorry, I don't think I was clear enough. The programs I used to convert the bitmaps were written for 16bit realmode dos, they don't use allegro. And it isn't allegro's fault that the image doesn't look right, as the error is in paint too. Actually, I'm guessing its something with my code. I have no idea what, it's just one of those strange errors caused by something you would think would have no effect on it. I did notice that after converting the bitmap to integers that my file contained 2 more 0's in a certain spot than before the file was converted. Weirdly, though, I counted up all of the 0's, and there weren't enough for the image in either file. I don't think that will make any since to you, but it makes sense to me. "Java is high performance. By high performance we mean adequate. By adequate we mean slow." -Mr. Bunny |
spellcaster
Member #1,493
September 2001
![]() |
Ok, that raises the question why you're not using allegro to convert the bitmaps? -- |
23yrold3yrold
Member #1,134
March 2001
![]() |
I don't know if this is relevant, but something worth noting is that the bitmap format pads the lines of pixel data in 24bpp so one line is always a multiple of 4 bytes in length. So if your bitmap is 15 pixels wide, and each color requires 3 bytes to store in 24bpp, that's 45 bytes per line. The bitmap format requires that be padded to 48 bytes per line (next multiple of 4). If you're not aware of/compensating for that when loading/saving 24bpp images, it'll mess up any image that isn't a multiple of 4 in width (those images will require no padding). -- |
Mr. Xboxor
Member #3,763
August 2003
![]() |
Yes, I know about the padding thing. That's not the reason, unless my calculations for how many blank bytes to put at the end of a line are incorrect. "Java is high performance. By high performance we mean adequate. By adequate we mean slow." -Mr. Bunny |
Korval
Member #1,538
September 2001
![]() |
Doesn't the bitmap format, also, require that each 24-bit entry have an addition 8-bits (used for nothing), to pad each entry out to 32-bits? Or does it actually support packed 24-bit textures? |
23yrold3yrold
Member #1,134
March 2001
![]() |
Packed. Otherwise the aforementioned padding would be pointless -- |
|