Re: Working with CGImage and Retina Display
Re: Working with CGImage and Retina Display
- Subject: Re: Working with CGImage and Retina Display
- From: Steve Christensen <email@hidden>
- Date: Wed, 15 Dec 2010 12:10:46 -0800
I believe the issue is that CGImage just refers to an image with an effective scale factor of 1.0, no matter the device scale. It sounds like you need to somehow keep track of the image scale you're using so that you're always drawing at the correct size. One way would be to use +[UIImage imageNamed:], which will automatically load the correct version of your map image. When you draw that image, it does so with the scale in mind.
On Dec 13, 2010, at 3:09 PM, Gustavo Pizano wrote:
> Hello all.
>
> Im creating some views which draws a CGImage that is obtained from a Atlas Map, (Big map containing all the images).
>
> for iPHone 4 I have this map 2 times bigger than the normal one, so if I have a 2.0 scale on screen I load that one.
>
> What Im getting is that on iPhone 4 Im seeing all the views are drawing the CGImage too big, like 2 times more. So i think this has something to do with the 2.0 scale factor.
>
> what should I do in order to draw the CGImage properly sized?
>
> this is my drawing method which is working on iPad...
>
> CGContextRef context = UIGraphicsGetCurrentContext();
>
> CGContextSaveGState(context);
> CGContextTranslateCTM(context, 0, CGImageGetHeight(bc_itemImage));
> CGContextScaleCTM(context, 1.0, -1.0);
> CGContextDrawImage(context, self.bounds, bc_itemImage);
> CGContextRestoreGState(context);
>
> and this is my init method
>
> -(id)initWithImageFrame:(CGRect)imgFrame fromSheet:(CGImageRef)sheet{
>
> self = [super initWithFrame:CGRectMake(0, 0, imgFrame.size.width, imgFrame.size.height)];
> if(self){
> bc_itemImage = CGImageCreateWithImageInRect(sheet,imgFrame);
> self.backgroundColor = [UIColor clearColor];
> bc_isInBox = YES;
> }
>
> return self;
> }
>
> Thanks in advance for any help provided.
>
> Gustavo
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden