对于iPhone,我正在用CGContextClipToMask裁剪一个图像。
在320x480,它看起来很漂亮。但是在视网膜显示器/模拟器中,掩蔽看起来像是在320x480中完成的,然后扩展到640x960,看起来有点粗糙。
正在使用正确的640x960图像(我已标记它们以确保)。
我的密码在下面。有人知道可能是什么吗?会非常感激你的帮助。非常感谢。
-(id)makeMainImage:(UIImage*)initMaskImg initMainImage:(UIImage*)initMainImage{
//get images
UIImage *mainImg = initMainImage;
UIImage *maskImg = initMaskImg;
//new context, to draw image into
UIGraphicsBeginImageContext(mainImg.size);
CGContextRef context = UIGraphicsGetCurrentContext();
//position context
CGContextTranslateCTM(context, 0,480);
CGContextScaleCTM(context, 1.0, -1.0);//flip coordinates
//rect
CGRect imageRect = CGRectMake(0, 0, 320, 480);
//set mask
CGContextClipToMask(context, imageRect, maskImg.CGImage);
//main image
CGContextDrawImage(context, imageRect, mainImg.CGImage);
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}发布于 2012-09-06 21:11:58
不要使用'UIGraphicsBeginImageContext',使用
UIGraphicsBeginImageContextWithOptions(size, opaque, 0); // last option is the scale option这就是你创建视网膜图像的方法。
https://stackoverflow.com/questions/12308206
复制相似问题