[C\C++] - about my Game header file

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
i build my own header file for build games. but by some reason the images arent showed:(
see these part of code://in header file:
struct Images
{
HBITMAP ImageImage;
BITMAP Imagebm;
HDC ImagehdcMem;
HBITMAP ImageMaskImage;
BITMAP ImageMaskbm;
HDC ImageMaskhdcMem;
};
//...............
int LoadImage(Images imagem, char *FileName,COLORREF MaskColor)
{
int posx;
int posy;

COLORREF b;


//Load the image
imagem.ImageImage = (HBITMAP)LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(imagem.ImageImage , sizeof(BITMAP), &imagem.Imagebm);
imagem.ImagehdcMem = CreateCompatibleDC(NULL);

//Create the mask
SelectObject(imagem.ImageMaskhdcMem, imagem.ImageMaskImage);
imagem.ImageMaskImage = (HBITMAP)LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(imagem.ImageMaskImage , sizeof(BITMAP), &imagem.ImageMaskbm);
imagem.ImageMaskhdcMem = CreateCompatibleDC(NULL);
SelectObject(imagem.ImageMaskhdcMem, imagem.ImageMaskImage);

if (MaskColor==-1) GetPixel(imagem.ImageMaskhdcMem,0,0);

for (posy=0;posy<imagem.Imagebm.bmHeight;posy++)
{
for (posx=0;posx<imagem.Imagebm.bmWidth ;posx++)
{
b=GetPixel(imagem.ImageMaskhdcMem,posx,posy);
if (b==MaskColor)
SetPixel(imagem.ImageMaskhdcMem,posx,posy,RGB(255,255,255));
else
SetPixel(imagem.ImageMaskhdcMem,posx,posy,RGB(0,0,0));
}
}
return 0;
}
and heres how i use:Images ImagePlayer;

//..............
LoadImage(ImagePlayer,"C:\test\Bleu Battle.bmp",-1);
//the information pass to ImagePlayer
//.....................
do i must use pointers to resolve it or its another error?
use the problem is the pointers, can anyone explain to me better?
(in the end i share the entire code;))

View the full article
 
Back
Top