我在带有视网膜显示屏的iPad上尝试GPUImage filter from this example。
最终图像比必要的图像大2倍。我想我必须设置正确的大小或比例因子,但是如何?
- (void)addBorder {
if (currentBorder != kBorderInitialValue) {
GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
GPUImagePicture *imageToProcess = [[GPUImagePicture alloc] initWithImage:self.imageToWorkWithView.image];
GPUImagePicture *border = [[GPUImagePicture alloc] initWithImage:self.imageBorder];
blendFilter.mix = 1.0f;
[imageToProcess addTarget:blendFilter];
[border addTarget:blendFilter];
[imageToProcess processImage];
[border processImage];
self.imageToWorkWithView.image = [blendFilter imageFromCurrentlyProcessedOutput];
[blendFilter release];
[imageToProcess release];
[border release];
}
}
答案 0 :(得分:2)
您可以使用[blendFilter forceProcessingAtSize:]
直接设置GPUImageFilter的输出大小。
答案 1 :(得分:1)
我找到了一个解决方案,虽然这是一个黑客攻击。
在GPUImageOutput中,添加:
- (UIImage *)imageFromCurrentlyProcessedOutputWithOrientation:(UIImageOrientation)imageOrientation scale:(CGFloat)scale { // Added by Franz
CGImageRef cgImageFromBytes = [self newCGImageFromCurrentlyProcessedOutputWithOrientation:imageOrientation];
UIImage *finalImage = [UIImage imageWithCGImage:cgImageFromBytes scale:scale orientation:imageOrientation];
CGImageRelease(cgImageFromBytes);
return finalImage;
}
- (UIImage *)imageFromCurrentlyProcessedOutputWithOrientation:(UIImageOrientation)imageOrientation;
{
return [self imageFromCurrentlyProcessedOutputWithOrientation:imageOrientation scale:1];
}
然后,您可以获得具有指定比例因子的视网膜显示图像。用法示例:
UIImage *filteredImage = [filter imageFromCurrentlyProcessedOutputWithOrientation:sourceImage.imageOrientation scale:sourceImage.scale];
我可以想象有一种更简单的方法。