Steve hello thanks for the reply.. it happens that I did a dirty work around here.
at application launch I load the CGImageRef map depending on the device scale factor, so if it is 2.0 i load a @2x map otherwise the SD map. then when initializing the view which contains the and draw a portion of the map, I divide the frame's with and height by the device scale factor, and then in the draw method I translate the context by the CGImageGetHeight(bc_itemImage)/scaleFactor , which at the end will will the view's bound's height, but to be sure I always take the CGImageRef height which never gets modified after doing transformation to the view. Te results a nice a sharp image is drawn in retina display, and its SD counterpart in the normal device without scale factor. I dunno if it was the best approach but it works. Im trying to avoid using UIImage, because i needed to load a CGImageRef form the map then convert to UIImage, so I wanted to skip one step here, + I dunno what benefits I gain/lose by using CGImageRef instead of the UIImage facade. Thanks for the reply once again Gustavo On Dec 15, 2010, at 9:10 PM, Steve Christensen wrote: > 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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com