Wednesday, March 31, 2010

[Cpp-Programming] Strange behavior.

I am working on my own graphics program to where I can write my own
bitmaps.

Part of the problem is that the bitmap function draws butmaps upside
down. So they have to be flipped.

These pieces of code are acting strange

void bitmap::display(HDC hdc, int ac, int dw){

HDC dc = CreateCompatibleDC(NULL);

VOID *pvBits;

HBITMAP hbitmap = CreateDIBSection(dc,&bInfo,
DIB_RGB_COLORS,
&pvBits,NULL,0 );

CopyMemory(pvBits, bits, (acc*dwn));

SelectObject(dc, hbitmap);
BitBlt(hdc, ac, dw, 16, 16 ,dc, 0, 0, SRCCOPY);
DeleteDC(dc);

}

My problems are in the constructor:

To make it work I have to have this command and the copy functioned
commented out.
delete [] bits;

bits = new BYTE[acc*dwn];
bits = flip();

BYTE* bitmap::flip(){

BYTE * temp = new BYTE[acc*dwn];

for (int index=0; index < dwn; index++)
//memcpy(&temp[((dwn-1) - index)*acc],
// &bits[index*acc], acc);


return temp;

}

If I don't use the flip command the program crashes. The only way the
program will run is if I have the flip command and not use the flip
algorithm. Why could the program be acting like this? What else can
I do or look to get my program to


--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

0 Comments:

Post a Comment

<< Home