nicklockwood / FXBlurView

[DEPRECATED]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blur 8 Bits Image will be crash

matthewyan opened this issue · comments

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;
    }
    ...
}

Try this fork: https://github.com/Vienta/FXBlurView
It adds conversion of non-ARGB8888 images into ARGB8888.