[Gridflow-cvs] [svn] commit: r5463 - /trunk/src/quartz.m

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Fri Apr 16 01:23:04 EDT 2010


Author: matju
Date: Fri Apr 16 01:23:03 2010
New Revision: 5463

Log:
[#out quartz] image : keep alive

Modified:
    trunk/src/quartz.m

Modified: trunk/src/quartz.m
==============================================================================
--- trunk/src/quartz.m (original)
+++ trunk/src/quartz.m Fri Apr 16 01:23:03 2010
@@ -42,6 +42,7 @@
 	uint8 *imdata;
 	int imwidth;
 	int imheight;
+	CGImageRef image;
   @public
 	FormatQuartz *boss;
 }
@@ -137,33 +138,30 @@
 	CLEAR(imdata,size);
 	NSSize s = {w,h};
 	[[self window] setContentSize: s];
-	return self;
-}
-
-- (id) initWithFrame: (NSRect)r {
-	[super initWithFrame: r];
-	imdata=0; imwidth=-1; imheight=-1;
-	[self imageHeight: 240 width: 320];
-	return self;
-}	
-
-- (id) drawRect: (NSRect)rect {
-	[super drawRect: rect];
-	if (![self lockFocusIfCanDraw]) return self;
-	CGContextRef g = (CGContextRef)
-		[[NSGraphicsContext graphicsContextWithWindow: [self window]]
-			graphicsPort];
 	CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
-	CGDataProviderRef dp = CGDataProviderCreateWithData(
-		NULL, imdata, imheight*imwidth*4, NULL);
+	CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, imdata, imheight*imwidth*4, NULL);
 	CGImageRef image = CGImageCreate(imwidth, imheight, 8, 32, imwidth*4, 
 		cs, kCGImageAlphaFirst, dp, NULL, 0, kCGRenderingIntentDefault);
 	CGDataProviderRelease(dp);
 	CGColorSpaceRelease(cs);
+	return self;
+}
+
+- (id) initWithFrame: (NSRect)r {
+	[super initWithFrame: r];
+	image=0; imdata=0; imwidth=-1; imheight=-1;
+	[self imageHeight: 240 width: 320];
+	return self;
+}	
+
+- (id) drawRect: (NSRect)rect {
+	[super drawRect: rect];
+	//if (![self lockFocusIfCanDraw]) return self;
+	CGContextRef g = (CGContextRef) [[NSGraphicsContext graphicsContextWithWindow: [self window]] graphicsPort];
 	CGRect rectangle = CGRectMake(0,0,imwidth,imheight);
-	CGContextDrawImage(g,rectangle,image);
-	CGImageRelease(image);
-	[self unlockFocus];
+	if (image) CGContextDrawImage(g,rectangle,image);
+	//CGImageRelease(image);
+	//[self unlockFocus];
 	return self;
 }
 



More information about the Gridflow-cvs mailing list