Tuesday, September 21, 2010

Give the proper Resolution of Image as it have

/* // before wiout high resolutions
#define kScreencapTopX 15
#define kScreencapTopY 65
#define kScreencapHeight 335
#define kScreencapWidth 290

 */
//With high resolutions
#define kScreencapTopX 30
#define kScreencapTopY 130
#define kScreencapHeight 670
#define kScreencapWidth 580

-(UIImage *) imageProperResolutions{
CGRect rect =CGRectMake(0,0,320,480);
///UIGraphicsBeginImageContext(rect.size);
UIGraphicsBeginImageContextWithOptions(rect.size,NO,2.0);
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
CGRect croppedFrame = CGRectMake(kScreencapTopX,kScreencapTopY,kScreencapWidth,kScreencapHeight);
CGImageRef finalCGImage;
finalCGImage= CGImageCreateWithImageInRect(image.CGImage, croppedFrame);//[self imageByCropping:image toRect:croppedFrame];
UIImage *finalImage =[UIImage imageWithCGImage:finalCGImage];
UIGraphicsEndImageContext();
//XXX memory managment?
return [finalImage retain];
}

No comments:

Post a Comment