Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blur 8 Bits Image will be crash #106

Open
matthewyan opened this issue Apr 24, 2015 · 1 comment
Open

Blur 8 Bits Image will be crash #106

matthewyan opened this issue Apr 24, 2015 · 1 comment

Comments

@matthewyan
Copy link

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;
    }
    ...
}
@mariancerny
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants