[futurebasic] a Question about drawing an image

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2010 : Group Archive : Group : All Groups

From: Walter Lenk <Walter_Lenk@...>
Date: Sat, 17 Jul 2010 15:26:27 -0400
I am in the process of converting some programs from FsSpecs to 
FsRefs and CFURLs, and I just want to check that how I am drawing an 
image (in an CGImageRef) to a page is OK. Here is the code that I am 
using to do this - it works, but have I missed anything or made any 
egregious errors?

Best,

Walter

===========================================
LOCAL FN Draw_Image(FileName$,rectPtr AS POINTER TO RECT)
  dim as CGImageRef       image
  dim as CGContextRef     windowCtx
  dim as CGRect           r
LET image = fn CreateCGImageFromBundleResourceFile( FileName$ )
IF (image == 0) THEN EXIT FN
' draw directly to a window
fn QDBeginCGContext( window( _wndPort ), @windowCtx )
' draw the image at the size and location of the incoming rect
'  NOTE: CG rects relate to bottom coordinates instead of the top coordinates
LET r = fn CGRectMake( 0, 0, rectPtr.right - rectPtr.left, 
rectPtr.bottom - rectPtr.top )
LET r = fn CGRectOffset( r, rectPtr.left, WINDOW(_height)-rectPtr.bottom )
FN CGContextDrawImage( windowCtx, r, image )
FN CGImageRelease( image )
fn QDEndCGContext( window( _wndPort ), @windowCtx )
END FN
===========================================

-- 

===========================================
Walter Lenk    Cambridge Ma    617-547-7781
===========================================