Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

StijnSpijker

macrumors newbie
Original poster
Jan 27, 2009
5
0
The Netherlands
Heya,

I've got an image (a single frame GIF, no animation), that has transparancy.
But when I add the UIImage to my IBOutlet UIImageView as a subview, the transparant part of my image is displayed black!?

This is how I made the transparant part of my image masked:
Code:
float trans = [[GIF_transparancies objectAtIndex:index] floatValue]; // This gets the color that should be transparant.
CGFloat colorMasking[6] = {trans, trans}; // Adding this 6 times (R, G , B) does not help/work, same effect -> black parts instead of transparant.
		
UIImage *image = [UIImage imageWithData:[GIF_framesData objectAtIndex:index]]; // Get the GIF and make an image out of it.
CGImageRef imageWithTransparancy = CGImageCreateWithMaskingColors([image CGImage], colorMasking); // Color mask it.
		
return [UIImage imageWithCGImage:imageWithTransparancy]; // Turn it back into a UIImage

So the 'colormasking' part works, the parts that I expected to be transparant become black.
Now I just want the black to become transparant :p...

Any help?
 
I would double-check the docs on the 2nd arg to the CGImageCreateWithMaskingColors function and make sure you're passing it the right data for the colorspace of the image.

Also you should CGImageRelease the image after creating the UIImage from it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.