

kCommandDrawImageFile : doDrawImageFile ( context, False ) elif drawingType = UIHandling. kCommandSimpleClip : doDrawImageFile ( context, True ) elif drawingType = UIHandling.

kCommandAlphaRects : drawAlphaRects ( context ) elif drawingType = UIHandling. kCommandStrokedAndFilledRects : drawStrokedAndFilledRects ( context ) elif drawingType = UIHandling. CFBundleCopyResourceURL ( mainBundle, kOurImageFile, None, None ) else : print ( "Can't get the app bundle!" ) if _ourImageURL : if doclip : clipImageToEllipse ( context, _ourImageURL ) else : drawCGImage ( context, _ourImageURL ) else : print ( "Couldn't create the URL for our Image file!" ) def myDispatchDrawing ( context, drawingType ): if drawingType = UIHandling. CFBundleGetMainBundle () if mainBundle : _ourImageURL = Cocoa. CGColorCreate ( myGetGenericRGBSpace (), ( 1, 0, 0, 1 )) return _red _ourImageURL = None def doDrawImageFile ( context, doclip ): global _ourImageURL if _ourImageURL is None : mainBundle = Cocoa. CGColorCreate ( myGetGenericRGBSpace (), ( 0, 1, 0, 1 )) return _green _red = None def myGetRedColor (): global _red if _red is None : _red = Quartz. CGColorCreate ( myGetGenericRGBSpace (), ( 0, 0, 1, 1 )) return _blue _green = None def myGetGreenColor (): global _green if _green is None : _green = Quartz.

kCGColorSpaceGenericRGB ) return _colorSpace _blue = None def myGetBlueColor (): global _blue if _blue is None : _blue = Quartz. pi / 180 _colorSpace = None def myGetGenericRGBSpace (): global _colorSpace if _colorSpace is None : _colorSpace = Quartz. BEST_BYTE_ALIGNMENT = 16 def COMPUTE_BEST_BYTES_PER_ROW ( bpr ): return ( bpr + ( BEST_BYTE_ALIGNMENT - 1 )) & ~ ( BEST_BYTE_ALIGNMENT - 1 ) def DEGREES_TO_RADIANS ( degrees ): return degrees * math. Import array import math import Cocoa import Quartz import UIHandling kOurImageFile = "ptlobos.tif" # For best performance make bytesPerRow a multiple of 16 bytes.
