🔒 Locked
Loading bitmaps
Advertisement
Original Post
Hey,
I am trying to load a bitmap image, I have the image in the same dir as the project code but for some reason the image still is not appearing?
Loading code: -
// load the 8-bit image
if (!Load_Bitmap_File(&bitmap,"bitmap8.bmp"))
return(0);
I have tried using a path such as c:\windows\etc.. to point to the dir of the image. I have also tried adding the bitmap file to the resources but still nothing?
This is an example from the TOTWGPG book and should work so I presume I am either doing something wrong with the path or doing something wrong with the compiler?
Any help appreciated.
Paul
Hey,
Forgive me if this is the wrong info but I am at the very very early stages of learning this:-
// container structure for bitmaps .BMP file
typedef struct BITMAP_FILE_TAG
{
BITMAPFILEHEADER bitmapfileheader; // this contains the bitmapfile header
BITMAPINFOHEADER bitmapinfoheader; // this is all the info including the palette
PALETTEENTRY palette[256]; // we will store the palette here
UCHAR *buffer; // this is a pointer to the data
} BITMAP_FILE, *BITMAP_FILE_PTR;
int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename);
The code should be okay as it is from a very good book and I haven''t had probs with the code before. I presume I am doing something wrong with the compiler rather than the code is wrong.
Paul
Forgive me if this is the wrong info but I am at the very very early stages of learning this:-
// container structure for bitmaps .BMP file
typedef struct BITMAP_FILE_TAG
{
BITMAPFILEHEADER bitmapfileheader; // this contains the bitmapfile header
BITMAPINFOHEADER bitmapinfoheader; // this is all the info including the palette
PALETTEENTRY palette[256]; // we will store the palette here
UCHAR *buffer; // this is a pointer to the data
} BITMAP_FILE, *BITMAP_FILE_PTR;
int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename);
The code should be okay as it is from a very good book and I haven''t had probs with the code before. I presume I am doing something wrong with the compiler rather than the code is wrong.
Paul
Hi,
The executable examples of the CD for the Tricks of the windows games programming gurus don''t work eithier 7_10.cpp - 7_12.cpp.
They load and I get a brief glimpse of the bitmap before it flashes off quickly less than a second. Could this be my card or my system setup or has this happened to anyone else before?
Pk.
The executable examples of the CD for the Tricks of the windows games programming gurus don''t work eithier 7_10.cpp - 7_12.cpp.
They load and I get a brief glimpse of the bitmap before it flashes off quickly less than a second. Could this be my card or my system setup or has this happened to anyone else before?
Pk.
Yes, it is from a good book. However, the Load_Bitmap_File() alone does not create the bitmap. This is one point of his book that I found unnecessarily complicated. Anyway, here is what you have to do, if you haven''t already:
As you can see, it is a little complex. If you have the DirectX 7 SDK or higher, it comes with some utility code in DDUtil.cpp, which has a function called: DDLoadBitmap(). For your program, you can just declare a surface pointer and call the funciton, then Blt to the drawing surface.
LPDIRECTDRAW7 lpdd;
LPDDSURFACEDESC7 lpddsmysurface;
lpddsmysurface=DDLoadBitmap(lpdd,"bitmap8.bmp",0,0);
lpddsprimary->Blt(etc etc....
There''s a little setup missing, but it is easy enough to figure out.
---
Make it work.
Make it right.
Make it fast.
|
As you can see, it is a little complex. If you have the DirectX 7 SDK or higher, it comes with some utility code in DDUtil.cpp, which has a function called: DDLoadBitmap(). For your program, you can just declare a surface pointer and call the funciton, then Blt to the drawing surface.
LPDIRECTDRAW7 lpdd;
LPDDSURFACEDESC7 lpddsmysurface;
lpddsmysurface=DDLoadBitmap(lpdd,"bitmap8.bmp",0,0);
lpddsprimary->Blt(etc etc....
There''s a little setup missing, but it is easy enough to figure out.
---
Make it work.
Make it right.
Make it fast.
quote:
Original post by Sir_Spritely
Hi,
The executable examples of the CD for the Tricks of the windows games programming gurus don''t work eithier 7_10.cpp - 7_12.cpp.
They load and I get a brief glimpse of the bitmap before it flashes off quickly less than a second. Could this be my card or my system setup or has this happened to anyone else before?
Pk.
No, it doesn''t work on mine either. Except, I just get a fuzzy sprite moving accross the screen. I think he hurried that part a little and didn''t test it out. I find the DDUtil in the SDK much easier to use.
---
Make it work.
Make it right.
Make it fast.
Cheers,
I think I kinda have it sorted in my head. I was struggling with it before this though
. I''ll have a play with it.
Pk
I think I kinda have it sorted in my head. I was struggling with it before this though
Pk
Well, i wrote my own .bmp loading class, but could not get my bitmaps to load into a direct draw back buffer. I have basically ditched Direct Draw, and will only use OpenGL for both 2D and 3D graphics. I am not that interested in Direct 3D, because I want to be able to port my engine to other computer systems, especially UNIX(Sun Solaris 8) and Linux. I have to test my Bitmap class with OpenGl now. I have the Andre Lamothe book, and it is good. .bmp work is tricky for me, though. I will code .tga and .jpg loaders.
Edem Attiogbe
Edited by - KwamiMatrix on December 4, 2001 11:58:13 AM
Edem Attiogbe
Edited by - KwamiMatrix on December 4, 2001 11:58:13 AM
Hey,
I am using DirectX V6 which is included with the Game Gurus book, just to make life easier. I guess the problem I am having now is, where to change the code in the program, I am very very very new to this and it was hard enough with the book examples working let alone not working. It looks like it''ll take me twice as long now
.
By the way, what is the DirectX SDK, LOL, I know this is a lame ? but, ohe well LOL.
Pk
I am using DirectX V6 which is included with the Game Gurus book, just to make life easier. I guess the problem I am having now is, where to change the code in the program, I am very very very new to this and it was hard enough with the book examples working let alone not working. It looks like it''ll take me twice as long now
By the way, what is the DirectX SDK, LOL, I know this is a lame ? but, ohe well LOL.
Pk
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement