Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-10-2010, 11:02 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
brian515 is on a distinguished road
Default Poor looking Quartz on Retina Display

Hey everyone,

I'm trying to update an app I have which lets the user draw with their finger. I do this in Quartz. However, when I test on the iPhone 4 (well, the simulator, actually, as I don't have an iPhone 4), the Quartz drawing looks pixelated.

They way I'm drawing is as follows:
In my UIView subclass, in the initWithFrame method, I have this:
Code:
		CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
		
		_myContext = CGBitmapContextCreate(NULL, self.frame.size.width, self.frame.size.height, 8, 
										   4*self.frame.size.width, colorSpace, kCGImageAlphaPremultipliedLast);
		
		drawingLayer = CGLayerCreateWithContext(_myContext, self.frame.size, NULL);
		CGContextRef layerContext = CGLayerGetContext(drawingLayer);
		CGContextSetLineWidth(layerContext, 10.0);
		CGContextSetLineCap(layerContext, kCGLineCapRound);
		drawingColor = [UIColor redColor];
		CGContextSetStrokeColorWithColor(layerContext, drawingColor.CGColor);
Then, in the drawRect method, I have this:
Code:
ctx = UIGraphicsGetCurrentContext();
	
	CGImageRef image = CGBitmapContextCreateImage(_myContext);
	CGContextDrawImage(ctx, self.bounds, image);
	CGImageRelease(image);
	
	CGContextDrawLayerInRect(ctx, self.bounds, drawingLayer);
And finally, in touchesMoved, I have this:
Code:
CGContextSetLineWidth(layerContext, pointSize);
				CGPoint pastLocation = [touch previousLocationInView:self];
			
				CGContextBeginPath(layerContext);
				CGContextMoveToPoint(layerContext, pastLocation.x, pastLocation.y);
				CGContextAddLineToPoint(layerContext, location.x, location.y);
				CGContextStrokePath(layerContext);
I believe the error is in this line
Code:
_myContext = CGBitmapContextCreate(NULL, self.frame.size.width, self.frame.size.height, 8, 
										   4*self.frame.size.width, colorSpace, kCGImageAlphaPremultipliedLast);
because if I change it to
Code:
_myContext = CGBitmapContextCreate(NULL, 640, 960, 8, 
										   4*self.frame.size.width, colorSpace, kCGImageAlphaPremultipliedLast);
everything looks sharp. However, when I do that, I get the
Code:
<Error>: CGBitmapContextCreateImage: invalid context 0x0
message.

Any help or suggestions would be greatly appreciated. Thanks!
brian515 is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone 4, pixelated, quartz, resolution, retina display

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 359
10 members and 349 guests
bignoggins, Chickenrig, firecall, givensur, iNet, linkmx, michaelhansen, Objective Zero, PlutoPrime, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:40 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0