Jump to content
  • Advertisement

Archived

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

emileej

>>Paradigm 2000: Problems with your bitmapdrawing rutine

This topic is 6089 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

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:
  
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

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!