LPDIRECTDRAWSURFACE CWINBitmap::DrawToSurface(IDirectDraw *pdd){
DDSURFACEDESC ddsd;
LPDIRECTDRAWSURFACE lpddsurface=CreateOffScreenSurface(pdd, GetWidth(), abs(GetHeight()));
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
unsigned char * videobuffer = NULL;
unsigned char * filebuffer = GetImagePtr();
lpddsurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
videobuffer = (unsigned char *)(ddsd.lpSurface);
int pointerscale = (GetColorDepth())>>3;
unsigned int padding = 4 - ((GetWidth()*pointerscale) % 4);
if(padding == 4)
padding = 0;
unsigned long linesize = (GetWidth()*pointerscale) + padding;
int j = 0;
if(GetHeight() > 0){
for(int i = GetHeight() - 1; i >= 0; i--){
memcpy(&videobuffer[j*ddsd.lPitch],&filebuffer[i*linesize],GetWidth()*pointerscale);
j++;
}
}else{
unsigned long height = -GetHeight();
for(int i = 0; i < GetHeight(); i++){
memcpy(&videobuffer[i*ddsd.lPitch],&filebuffer[i*linesize],GetWidth()*pointerscale);
}
}
lpddsurface->Unlock(videobuffer);
return lpddsurface;
}
-------------
E-)mil
http://eej.dk
- Just another crazy dane
>>Paradigm 2000: Problems with your bitmapdrawing rutine
Please write me - in that way it''ll be much less complicated - solving problems in your WinBitmap class.
This code draws the bitmap data, but all messed up - not eaven the colors match:
Just for the record, there''s no problem with my class. I''m e-mailing you now.
Paradigm Shift 2000
Paradigm Shift 2000
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement