很抱歉今天有这么多问题,周五出现死脑症状。
我有一个 CICrop 过滤器:
[crop setValue:beginImage forKey:@"inputImage"]; //give the crop filter the beginImage
[crop setValue:[CIVector vectorWithX:0.0f Y:0.0f Z:_exportSize W:_exportSize] forKey:@"inputRectangle"]; //give the filter the size to crop to
croppedImage = [crop valueForKey:@"outputImage"]; //set the output image, note it's still a CIImage at this point
遗憾的是,它不起作用。它裁剪的图像最终为 0x0 像素。 _exportSize(这是一个 CGFloat)的快速 NSLog 显示它是 1024,但日志显示图像裁剪后是 0x0。我不知道为什么。
此代码之前有效。我认为,唯一的区别是我以前裁剪 UIImage 而不是 CIImage。我宁愿不必转换,因为我计划在裁剪后做其他 CoreImage 的东西。
正如我所说,_exportSize 是一个 CGFloat _exportSize;记录它会显示它是 1024.0000。
有什么想法吗?
干杯。
最佳答案
最后我放弃了 Core Image 的裁剪,转而使用它:
-(UIImage *)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect
{
CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect);
UIImage *cropped = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return cropped;
}
关于ios - CoreImage CICrop 返回 0x0 像素图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10553321/