Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Problem with Image mask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with Image mask

On Sep 11, 2010, at 4:45 PM, Paul Reilly wrote:

I have an app which cuts out shapes from a picture. It works great - I can cut the shape using a mask, with the code shown below. My problem is, if I save the cut out image to disk, it has to go through NSData with UIImagePNGRepresentation and this seems to be reversing the effect of my mask. You can see the result in the following picture.

Can someone tell me where I am going wrong? Why does saving the UIImage to disk (going through NSData) reverse the effect of my image mask?

CGImageCreateMask and CGImageCreate generate CGImages that when used for masking are treated as inverses of each other (this is described in the documentation for CGImageClipToMask). For consistency I would recommend adopting the the "inverse" definition used by creating an image via CGImageCreate, which basically amounts to using the image's alpha as a multiplier against the incoming pixels (vs CGImageCreateMask which first inverts the alpha value).


Reality is what, when you stop believing in it, doesn't go away.

Failure is not an option. It is a privilege reserved for those who try.

David Duncan

Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 >Problem with Image mask (From: Paul Reilly <email@hidden>)

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.