开发者

saving images in documents folder with high resolution in iphone

I want to save image which is draw on iphone screen in th开发者_如何转开发e documents folder with high resolution. Here I am able to save images in documents folder but the resolution is very low . Can anyone tell me how to achieve this task.

Here is my Code

    UIImage *image = [[UIImage alloc]init];
double resolution = 50;

    //CGSize pageSize = CGSizeMake(612, 792);
    // CGRect boundsRect = CGRectMake(50, 50, 512, 692);
CGRect boundsRect = CGRectMake(0, 0, 612, 792);

double imageWidth = image.size.width * image.scale * 72 / resolution;
double imageHeight = image.size.height * image.scale * 72 / resolution;

double sx = imageWidth / boundsRect.size.width;
double sy = imageHeight / boundsRect.size.height;

    // At least one image edge is larger than maxBoundsRect
if ((sx > 1) || (sy > 1)) {
    double maxScale = sx > sy ? sx : sy;
    imageWidth = imageWidth / maxScale;
    imageHeight = imageHeight / maxScale;
}

    // Put the image in the top left corner of the bounding rectangle
CGRect bounds = CGRectMake(boundsRect.origin.x, boundsRect.origin.y + boundsRect.size.height - imageHeight, imageWidth, imageHeight);

CGSize size = bounds.size;

    //  UIGraphicsBeginImageContextWithOptions(size,NO,10.0f); 

UIGraphicsBeginImageContext(size);
{
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    image = UIGraphicsGetImageFromCurrentImageContext();

}


Try this:

- (UIImage *)screenshotImage {
    UIView* screen = self.view;
    CGSize imageSize = screen.bounds.size;

    UIGraphicsBeginImageContext(imageSize);
    CGContextRef imageContext = UIGraphicsGetCurrentContext();
    [screen.layer renderInContext: imageContext];
    UIImage* screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return screenshotImage;
}

After receive image and save it:

UIImage *screenshotImage = [self screenshotImage];
UIImageWriteToSavedPhotosAlbum(screenshotImage,nil,nil,nil);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜