Reputation: 1937
I'm having some trouble with weird results being produced from getting raw data and editing alpha values of a UIImage
on the iPhone. If the pixel colour touched is not all black on touch, it does not look like full alpha. Following are the results:
Start unmodified
Grey touched to turn all grey to alpha = 0
And then if I touch the weird whitewash area which is supposedly alpha 0, it turns all pixels that are completely black to alpha 0 even though technically
//No link dont have enough rep//
Does anyone have any clue what is going on? Is it something to do with pre-multiplied alpha? Or perhaps the way I'm editing the values. If you require the code to look at, let me know and I will edit it in.
As an additional note, the grey area the second time round upon pressing the whitewash area, instead of the alpha just being 0 all the other values are equal to 0, when they should have been left as they are.
Upvotes: 2
Views: 409
Reputation: 1937
Right, through Experimentation, trial and error and shear luck i have discovered the solution to the problem, I don't know the reason but this fixed it.
when getting the raw data i use this function to get the bitmap info in the context
CGBitmapInfo imageInfo = CGImageGetBitmapInfo(imageRef);
and was using the same variable to then create the CGImage from the edited raw data. And thus the madness
The method to fix it is instead of using "imageInfo" upon creation from raw data, is to use the flag kCGImageAlphaLast
.
Fixed, not a clue why though.
Upvotes: 1