hi i m check that the image has a transparent area (alpha) or not. Due to the fact that I need to change the color of the UIImage
I use the method below to check the alpha image or not.
- (BOOL) checkAlpha : (UIImage*) image { for(int x = 0; x < image.size.width ; x++) { for(int y = 0; y < image.size. height; y++) { CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage)); const UInt8* data = CFDataGetBytePtr(pixelData); int pixelInfo = ((image.size.width * y) + x ) * 4;
This method works fine, but for some image it creates a problem. See image below.
For this image, alpha returns 0;
And for the above 2 images, alpha has some meaning.
All 3 images have the same white background. There must also be alpha for the first image. it should not be 0. Please help me find out about this? is there any code error in my method or what?
ios objective-c uiimage alpha-transparency
Hitarth Aug 17 '16 at 14:21 2016-08-17 14:21
source share