Re: Masking UIImages (yes, again)
Re: Masking UIImages (yes, again)
- Subject: Re: Masking UIImages (yes, again)
- From: Gustavo Pizano <email@hidden>
- Date: Mon, 27 Jun 2011 08:03:28 +0200
I was on the same boat a few weeks ago and I wanted to ask something similar but I completely forgot.
I was trying to mask an image with a mask image created from a bezier path, the idea was that I created my bezier path then I fill EO the path so the part that was supposed to mask I left it of white color and the rest was black, then I created an image from that path using the UIGpraphicContext methods. The image was created successfully, then I created the mask form that image passing the bits per row, etc, and when I apply the mask to the image I wanted to mask I left all fine expect the part that was supposed to mask (and leave transparent), this part was black.
After checking everything and realizing all was ok, I desisted on using CG and used instead CALayer, I set the contents to the mask image and then CALayer has a mask method that seemed to work fine. But I really wanted to make it work with CG. :(
Gustavo
On Jun 27, 2011, at 1:03 AM, Luke Hiesterman wrote:
>
>
> On Jun 26, 2011, at 3:06 PM, "James Miller" <email@hidden> wrote:
>
>> I've been reading and experimenting and browsing and reading and experimenting but mostly failing miserably here and I need to ask the hive mind for some assistance.
>>
>> In a nutshell, I'm just trying to take a range of white colors out of a UIImage and make those colors transparent. From what I've read, I shouldn't use PNGs with an alpha already defined, but I also shouldn't use JPGs because they don't have an alpha channel.
>
> Where did you read that you shouldn't use PNGs with alpha?
>
>>
>> So I've been trying to the extract the UIImage's CGImage and then convert it from RGB to RGBA and THEN mask it with CGImageCreateWithMaskingColors with no success (transparent areas appear as black). I've tried various techniques involving CGBitmapContextCreate and CGImageCreate but with no luck.
>
> Note that if you did successfully make parts of your image transparent, they would show up as black if drawn into an opaque context. How are you drawing/displaying the image?
>
> Luke
>
>>
>> This can't POSSIBLY be as complicated as I'm making this out to be! Can someone please show me how to do this properly!?
>>
>> A thousand thank yous and a pet herring named after you!
>>
>> --James
>>
>>
>>
>>
>> "The world is divided into people who do things and people who get the credit. Try, if you can, to belong to the first class. There's far less competition."
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden