D3D7Max2D Tweak: GrabPixmap()

BlitzMax Forums/BlitzMax Module Tweaks/D3D7Max2D Tweak: GrabPixmap()

Ked(Posted 2009) [#1]
Little speed optimization I put together: Line 466
Method GrabPixmap:TPixmap( x,y,width,height )
	If Not IsValid() Return
	
	Local pixmap:TPixmap
	Local srcdc,destdc
	Local surf:IDirectDrawSurface7
	Local renderSurf:IDirectDrawSurface7
	Local rect[]=[x,y,width,height]
	
	D3D7GraphicsDriver().EndScene

	device.GetRenderTarget Varptr renderSurf
	
	pixmap=TPixmap.Create( width,height,PF_BGR888 )
	surf=surffrompixmap( pixmap )
	surf.BltFast(0,0,rendersurf,Byte Ptr(rect),DDBLTFAST_NOCOLORKEY)
	surf.Release_()
	D3D7GraphicsDriver().BeginScene

	Return pixmap	
End Method

With this it is faster than GLMax2D's GrabPixmap code on my machine.


Ked(Posted 2009) [#2]
Nevermind! This doesn't work with height set at 1.