Blur 8 Bits Image will be crash
matthewyan opened this issue · comments
matthewyan commented
My image is 8 bit gray image, when I blur it, it crashed
I fixed by this code:
- (UIImage *)blurredImageWithRadius:(CGFloat)radius iterations:(NSUInteger)iterations tintColor:(UIColor *)tintColor
{
//image must be nonzero size
if (floorf(self.size.width) * floorf(self.size.height) <= 0.0f) return self;
//boxsize must be an odd integer
uint32_t boxSize = (uint32_t)(radius * self.scale);
if (boxSize % 2 == 0) boxSize ++;
//create image buffers
CGImageRef imageRef = self.CGImage;
// Here:fix crash
size_t sizeBit = CGImageGetBitsPerPixel(imageRef);
if (sizeBit == 8) {
return self;
}
...
}
Marián Černý commented
Try this fork: https://github.com/Vienta/FXBlurView
It adds conversion of non-ARGB8888 images into ARGB8888.