How to access the content of BITBLT ?

Blitz3D Forums/Blitz3D Userlibs/How to access the content of BITBLT ?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Are you ok with compiling a DLL? If not lemme know and I'll whip one up.

This code will blit from any HWND direct to a BB Image

BBDECL int BBCALL BitBlitHWND2Image(HWND hnd, unsigned int buffer, int sx, int sy, int sw, int sh, int dx, int dy)
{
	HRESULT hr;
	int srcFrame=0;
	buffer = (unsigned int) *((int*)(buffer+4));
	buffer = (unsigned int) *((int*)(buffer+(4 * srcFrame)));

	IDirectDrawSurface7 *destTex=NULL;
	destTex = (IDirectDrawSurface7*) *((int*)(buffer+12));

	HDC sDC=0;
	HDC dDC=0;

	sDC=GetDC(hnd);
	if(!sDC) return 0;

	hr=destTex->GetDC(&dDC);
	if(FAILED(hr))
	{
		ReleaseDC(hnd,sDC);
		return hr;
	}

	BOOL result=BitBlt(dDC,sx,sy,sw,sh,sDC,dx,dy,SRCCOPY);
	destTex->ReleaseDC(dDC);
	ReleaseDC(hnd,sDC);
	return result;
}

Note that I've left out the source frame from the parameters, you can just add it in if you wish (does work:)


Here's an example of calling it, I'm using GetDesktopWindow() so you'll need to have that setup in your user32.decls for this test:

Graphics 800,600,32,2

image=CreateImage(512,512)
srcHWND=api_GetDesktopWindow()


While Not KeyDown(1)
	BitBlitHWND2Image(srcHWND,image,0,0,512,512,0,0)
	DrawImage image,MouseX(),MouseY()

	Flip
Wend
End


Cya!
Tom