报错代码如下:
- (UIImage *)changeValueForBrightnessFilter:(float)value image:(UIImage *)image;
{
GPUImageBrightnessFilter *filter = [[GPUImageBrightnessFilter alloc] init];
filter.brightness = value/100;
GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:image];
[filter forceProcessingAtSize:image.size];
[pic addTarget:filter];
[pic processImage];
[filter useNextFrameForImageCapture];
return [filter imageFromCurrentFramebuffer];
}
报错提示:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error at CVOpenGLESTextureCacheCreateTextureFromImage -6683'
terminating with uncaught exception of type NSException
解决办法
加入如下代码:
CGSize outputImgSize = pic.outputImageSize;
[filter forceProcessingAtSize:outputImgSize];
原因:
目前iOS设备 GPU处理的矩阵最大为40964096 ,超过这么大的尺寸GPU渲染,则会失败,
使用GPUImagePicture的outputImageSize输出尺寸,作为滤镜的渲染尺寸。
因为GPUImagePicture的outputImageSize会对图片尺寸按40964096的最大尺寸等比进行缩放。
网友评论