对于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;
}
最佳答案
不要使用'UIGraphicsBeginImageContext',请使用
UIGraphicsBeginImageContextWithOptions(size, opaque, 0); // last option is the scale option
这是创建视网膜图像的方式。
关于iphone - 视网膜中的ClipToMask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12308206/