def testFunctions(self): bytes_val = array.array("B", (0 for i in range(100 * 80 * 4))) self.assertIsInstance(bytes_val, array.array) self.assertEqual(len(bytes_val), 100 * 80 * 4) ctx = Quartz.CGBitmapContextCreate( bytes_val, 100, 80, 8, 400, Quartz.CGColorSpaceCreateDeviceRGB(), Quartz.kCGImageAlphaPremultipliedLast, ) self.assertIsInstance(ctx, Quartz.CGContextRef) buf = Quartz.CGBitmapContextGetData(ctx) self.assertIsInstance(buf, objc.varlist) self.assertIsInstance(buf[0], bytes) self.assertEqual(Quartz.CGBitmapContextGetWidth(ctx), 100) self.assertEqual(Quartz.CGBitmapContextGetHeight(ctx), 80) self.assertEqual(Quartz.CGBitmapContextGetBitsPerComponent(ctx), 8) self.assertEqual(Quartz.CGBitmapContextGetBitsPerPixel(ctx), 32) self.assertEqual(Quartz.CGBitmapContextGetBytesPerRow(ctx), 400) v = Quartz.CGBitmapContextGetColorSpace(ctx) self.assertIsInstance(v, Quartz.CGColorSpaceRef) v = Quartz.CGBitmapContextGetAlphaInfo(ctx) self.assertIsInstance(v, int) v = Quartz.CGBitmapContextGetBitmapInfo(ctx) self.assertIsInstance(v, int) img = Quartz.CGBitmapContextCreateImage(ctx) self.assertIsInstance(img, Quartz.CGImageRef)
def myCGContextGetBitmapInfo(c): if hasattr(Quartz, "CGBitmapContextGetBitmapInfo"): return Quartz.CGBitmapContextGetBitmapInfo(c) else: return Quartz.CGBitmapContextGetAlphaInfo(c)