使用renderInContext:或CGImageCreateWithImageInRect解决方案丢失?

时间:2011-03-09 02:12:19

标签: iphone

我正在拍摄屏幕截图并裁剪导航栏/状态栏。我不认为它在上下文中裁剪是有效的,所以我使用CGImage组件进行裁剪。生成的图像比我在屏幕上看到的原始图像更像素化。使用图层组件是否禁用石英渲染?我在其中一次转换中丢失了分辨率吗?

我正在使用scrollView来进行缩放/平移,并保存按屏幕大小裁剪的图像。图像来自UIImagePickerController。有没有更好的方法呢?我是新手,欢迎提出建议。

    CGRect rect = CGRectMake(0, 44, 320, 436);
CGSize size = CGSizeMake(320, 480);

UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();

[self.view.layer renderInContext:context]; 
UIImage *tempImage = UIGraphicsGetImageFromCurrentImageContext();
CGImageRef ref = CGImageCreateWithImageInRect(tempImage.CGImage,rect);

finishedImage = [UIImage imageWithCGImage:ref];

[card saveImage:finishedImage];
UIGraphicsEndImageContext();

..... ..... UPDATE
我已经淘汰了:
    CGImageCreateWithImageInRect(问题在它被调用之前)
    scrollview(没有效果)
    上下文插值(已经开启,尝试不同的设置)
    来自imagePicker的图像(低rez pic从imagePicker直接看起来比从renderInContext看起来更好)

大多数分辨率都很好。它只是在放大和裁剪或低分辨率图片时,看起来比原版更糟糕。

0 个答案:

没有答案
相关问题