From 925d8437f7b3123cce8d6838a8c1501a8b9d50a3 Mon Sep 17 00:00:00 2001 From: Belimoth Date: Wed, 23 Jul 2014 17:59:16 -0500 Subject: [PATCH 1/2] --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d7a6c317..abf56ef7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ !/targets/winrt_win8 !/targets/winrt_winphone8 !/targets/xna +src/.bmx/rebuildall.bmx.console.release.win32.x86.o +src/.bmx/rebuildall.bmx.console.release.win32.x86.s From bc59f931ceb676b0d2dd6e133aeecfccc66312ed Mon Sep 17 00:00:00 2001 From: Belimoth Date: Wed, 23 Jul 2014 18:03:37 -0500 Subject: [PATCH 2/2] Convenient DrawImage and DrawImageRect variants. --- modules/mojo/graphics.monkey | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/modules/mojo/graphics.monkey b/modules/mojo/graphics.monkey index 4a0e4118..5df7aebe 100644 --- a/modules/mojo/graphics.monkey +++ b/modules/mojo/graphics.monkey @@ -492,6 +492,32 @@ Function DrawImage( image:Image,x#,y#,rotation#,scaleX#,scaleY#,frame=0 ) PopMatrix End +Function DrawImage( image:Image,x#,y#,m#[],frame=0 ) + + #If CONFIG="debug" + DebugRenderDevice + If frame<0 Or frame>=image.frames.Length Error "Invalid image frame" + #End + + Local f:Frame=image.frames[frame] + + PushMatrix + + Translate x,y + Transform m + Translate -image.tx,-image.ty + + context.Validate + + If image.flags & Image.FullFrame + renderDevice.DrawSurface image.surface,0,0 + Else + renderDevice.DrawSurface2 image.surface,0,0,f.x,f.y,image.width,image.height + Endif + + PopMatrix +End + Function DrawImageRect( image:Image,x#,y#,srcX,srcY,srcWidth,srcHeight,frame=0 ) #If CONFIG="debug" @@ -531,6 +557,29 @@ Function DrawImageRect( image:Image,x#,y#,srcX,srcY,srcWidth,srcHeight,rotation# PopMatrix End +Function DrawImageRect( image:Image,x#,y#,srcX,srcY,srcWidth,srcHeight,m#[],frame=0 ) + + #If CONFIG="debug" + DebugRenderDevice + If frame<0 Or frame>=image.frames.Length Error "Invalid image frame" + If srcX<0 Or srcY<0 Or srcX+srcWidth>image.width Or srcY+srcHeight>image.height Error "Invalid image rectangle" + #End + + Local f:Frame=image.frames[frame] + + PushMatrix + + Translate x,y + Transform m + Translate -image.tx,-image.ty + + context.Validate + + renderDevice.DrawSurface2 image.surface,0,0,srcX+f.x,srcY+f.y,srcWidth,srcHeight + + PopMatrix +End + Function ReadPixels( pixels[],x,y,width,height,offset=0,pitch=0 ) If Not pitch pitch=width