load image from buffer
hi, many new year!
Q:
so I have this cool image, in a packed file, I extract the image into a buffer, the buffer now contains the image, a full BMP file.
now I want to put it on a surface, so I do the follwing:
HBITMAP hbm;
DDSURFACEDESC2 ddsd;
LPDIRECTDRAWSURFACE7 pdds = NULL;
LPDIRECTDRAW7 pdd = *m_pEngine;
if( source == NULL ) return NULL;
PBITMAPFILEHEADER pfbmp = (PBITMAPFILEHEADER)source;
PBITMAPINFO pibmp = (PBITMAPINFO)(source+sizeof(BITMAPFILEHEADER));
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = pibmp->bmiHeader.biWidth;
ddsd.dwHeight = pibmp->bmiHeader.biHeight;
if (pdd->CreateSurface(&ddsd, &pdds, NULL) != DD_OK){
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
if (pdd->CreateSurface(&ddsd, &pdds, NULL) != DD_OK) return NULL;
}
DDCopyBitmap(pdds, hbm, 0, 0, 0, 0);
DeleteObject(hbm);
return pdds;
now some times the thing works, but most of the time when I blit this image, I get crap.
anybody knows whats the deal here?
(: I am what I am, more or less
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement