bitmap hell
Im using the GDI to make a tile based game. Yea I know the GDI sucks, but I want the practice. The way I was told to read in a bitmap file is to read in these structs:
BITMAPFILEHEADER
BITMAPINFOHEADER
Then check the bit depth and if necessary, read in
sizeof(PALLETTEENTRY) * 256
Followed ofcourse by the bitmap data. This works well, I can read in, and then output a bitmap just fine using this code. Even the bitmaps that come with Windows 2000 work. The problem I''m having is that Windows does not use this format for bitmaps. It uses a BITMAPINFO struct which I do not know how to get. Since I''m loading these bitmaps from files, I assume I need to use the CreateDIBitmap() function... I have everything I need in the parameter list from my format, except the damn BITMAPINFO struct. Where can I get this struct from, and how can I initialize it properly. I''m really stuct here so I totally appreciate your help!!
There is no spoon.
You could just use LoadImage function instead...
But, the BITMAPINFO structure just contains the headers:
typedef struct tagBITMAPINFO { // bmi
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
Jim Adams
But, the BITMAPINFO structure just contains the headers:
typedef struct tagBITMAPINFO { // bmi
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
Jim Adams
Jim Adams, Author"Programming Role-Playing Games with DirectX""Advanced Animation with DirectX""Programming Role-Playing Games with DirectX, 2nd Edition"
I cant use LoadImage() because the bitmap is not loaded from the file in the program it is used. I first load the bitmap using the format above in my wad file program. Then the game''s LoadMap() function read''s those same structs out of the wad and into an array. I doubt LoadImage() will work with a file name, a size, and an offset. =)
As for BITMAPINFO :
typedef struct tagBITMAPINFO { // bmi
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
I could always copy the BITMAPINFOHEADER straight across, but where would I get the values for RGBQUAD?
As for BITMAPINFO :
typedef struct tagBITMAPINFO { // bmi
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
I could always copy the BITMAPINFOHEADER straight across, but where would I get the values for RGBQUAD?
There is no spoon.
For an explanation and example of how to load bitmaps using GDI functions, check out my GDI tutorial at my website: aeon-software.com.
EDIT: I posted this without fully understanding what you said in the last post, so my article will probably be of no help to you, heh. Sorry, I've been awake for the better part of two days.
-Ironblayde
Aeon Software
Edited by - Ironblayde on August 23, 2000 10:06:18 PM
EDIT: I posted this without fully understanding what you said in the last post, so my article will probably be of no help to you, heh. Sorry, I've been awake for the better part of two days.
-Ironblayde
Aeon Software
Edited by - Ironblayde on August 23, 2000 10:06:18 PM
"Your superior intellect is no match for our puny weapons!"
quote: Original post by Orpheum
I cant use LoadImage() because the bitmap is not loaded from the file in the program it is used. I first load the bitmap using the format above in my wad file program. Then the game''s LoadMap() function read''s those same structs out of the wad and into an array. I doubt LoadImage() will work with a file name, a size, and an offset. =)
As for BITMAPINFO :
typedef struct tagBITMAPINFO { // bmi
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
I could always copy the BITMAPINFOHEADER straight across, but where would I get the values for RGBQUAD?
Doh! I''m having the same problem as you...if you find a solution please tell me
August 24, 2000 02:42 AM
quote: Original post by Orpheum
I cant use LoadImage() because the bitmap is not loaded from the file in the program it is used. I first load the bitmap using the format above in my wad file program. Then the game''s LoadMap() function read''s those same structs out of the wad and into an array. I doubt LoadImage() will work with a file name, a size, and an offset. =)
As for BITMAPINFO :
typedef struct tagBITMAPINFO { // bmi
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
I could always copy the BITMAPINFOHEADER straight across, but where would I get the values for RGBQUAD?
Doh! I''m having the same problem as you...if you find a solution please tell me
quote: Original post by Orpheum
I cant use LoadImage() because the bitmap is not loaded from the file in the program it is used. I first load the bitmap using the format above in my wad file program. Then the game''s LoadMap() function read''s those same structs out of the wad and into an array. I doubt LoadImage() will work with a file name, a size, and an offset. =)
As for BITMAPINFO :
typedef struct tagBITMAPINFO { // bmi
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
I could always copy the BITMAPINFOHEADER straight across, but where would I get the values for RGBQUAD?
Doh! I''m having the same problem as you...if you find a solution please tell me
The RGBQUAD values are the palette entries that you read from the file if it is a paletted bitmap.
you should allocate space for the BITMAPINFO struct using
(or similar using 'new' if you prefer)
and the you can access the bmiColors member in BITMAPINFO as an array containing number_of_palette_entries entries.
// Gaijin
"There is only one way to find out if a man is honest...ask him. If he says yes, you know he is crooked." -- Groucho Marx
"Sex isn't the answer. Sex is the question. 'Yes' is the answer" -- Unknown
Edited by - Gaijin on August 24, 2000 9:20:38 AM
you should allocate space for the BITMAPINFO struct using
BITMAPINFO bmi = malloc(sizeof(BITMAPINFOHEADER) + number_of_palette_entries*sízeof(RGBQUAD));
(or similar using 'new' if you prefer)
and the you can access the bmiColors member in BITMAPINFO as an array containing number_of_palette_entries entries.
// Gaijin
"There is only one way to find out if a man is honest...ask him. If he says yes, you know he is crooked." -- Groucho Marx
"Sex isn't the answer. Sex is the question. 'Yes' is the answer" -- Unknown
Edited by - Gaijin on August 24, 2000 9:20:38 AM
// Gaijin"There is only one way to find out if a man is honest...ask him. If he says yes, you know he is crooked." -- Groucho Marx"Sex isn't the answer. Sex is the question. 'Yes' is the answer" -- Unknown
umm that isnt going to work... all that would give me is an uninitialized chunk of memory sizeof(BITMAPINFO). And I somehow doubt that reading in (sizeof(PALLETTEENTRY) * 256) into the RGBQUAD struct will work either. Please prove me wrong - I need a solution!!
There is no spoon.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement