Archived

This topic is now archived and is closed to further replies.

load image from buffer

This topic is 5830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites