<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to Mask an Image</title>
	<atom:link href="http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html</link>
	<description>Tips and Tricks for iPhone developers</description>
	<lastBuildDate>Wed, 08 Sep 2010 06:15:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Christoph B</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-23710</link>
		<dc:creator>Christoph B</dc:creator>
		<pubDate>Fri, 20 Aug 2010 16:24:46 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-23710</guid>
		<description>A shame, I thought I got rid of the black border, then I built it to the device and back there it was. :( 

Any ideas?

Cheers,
Christoph</description>
		<content:encoded><![CDATA[<p>A shame, I thought I got rid of the black border, then I built it to the device and back there it was. :( </p>
<p>Any ideas?</p>
<p>Cheers,<br />
Christoph</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-23124</link>
		<dc:creator>Brandon</dc:creator>
		<pubDate>Tue, 10 Aug 2010 16:20:32 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-23124</guid>
		<description>In addition to Jean and Xavier&#039;s code, I have added one more condition for the alpha channel check:

	if ((CGImageGetAlphaInfo(sourceImage) == kCGImageAlphaNone)
		&#124;&#124; (CGImageGetAlphaInfo(sourceImage) == kCGImageAlphaNoneSkipFirst)
		&#124;&#124; (CGImageGetAlphaInfo(sourceImage) == kCGImageAlphaNoneSkipLast)) { 
		imageWithAlpha = CopyImageAndAddAlphaChannel(sourceImage);
	}</description>
		<content:encoded><![CDATA[<p>In addition to Jean and Xavier&#8217;s code, I have added one more condition for the alpha channel check:</p>
<p>	if ((CGImageGetAlphaInfo(sourceImage) == kCGImageAlphaNone)<br />
		|| (CGImageGetAlphaInfo(sourceImage) == kCGImageAlphaNoneSkipFirst)<br />
		|| (CGImageGetAlphaInfo(sourceImage) == kCGImageAlphaNoneSkipLast)) {<br />
		imageWithAlpha = CopyImageAndAddAlphaChannel(sourceImage);<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Forrest</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-20302</link>
		<dc:creator>Forrest</dc:creator>
		<pubDate>Sat, 17 Jul 2010 05:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-20302</guid>
		<description>question about how to creating mask image with programming way :

as we know, we can create such mask image via loading or reading one mask image edited already. 

but what I want now is to create those data via some codes, just like GDI+ does, any clues ? 

thanks</description>
		<content:encoded><![CDATA[<p>question about how to creating mask image with programming way :</p>
<p>as we know, we can create such mask image via loading or reading one mask image edited already. </p>
<p>but what I want now is to create those data via some codes, just like GDI+ does, any clues ? </p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nishant</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-17896</link>
		<dc:creator>nishant</dc:creator>
		<pubDate>Thu, 24 Jun 2010 12:48:16 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-17896</guid>
		<description>Thank&#039;s Rodney, this really helps perfect, which i am looking for! Thanks again!</description>
		<content:encoded><![CDATA[<p>Thank&#8217;s Rodney, this really helps perfect, which i am looking for! Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MN</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-15939</link>
		<dc:creator>MN</dc:creator>
		<pubDate>Thu, 27 May 2010 09:45:58 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-15939</guid>
		<description>Can we use CGImageCreateCopyWithColorSpace(maskref,CGColorSpaceCreateDeviceGray()) instead of CGImageMaskCreate(All the parameters and separate method calls)?</description>
		<content:encoded><![CDATA[<p>Can we use CGImageCreateCopyWithColorSpace(maskref,CGColorSpaceCreateDeviceGray()) instead of CGImageMaskCreate(All the parameters and separate method calls)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casey</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-15465</link>
		<dc:creator>Casey</dc:creator>
		<pubDate>Tue, 18 May 2010 07:44:17 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-15465</guid>
		<description>SOLUTION!!

Ok, this is stupidly easy to do after figuring out. The main problem is the mask image but after hours of banging my head on my desk I figured it out. Use whatever software you wish to create the mask.png with whatever colors you want and save it. The trick is to open it in Preview, yes Preview and click Save As, DESELECT the Alpha button and save. Your mask is now finished.


-(UIImage*)maskImage:(UIImage*)image withMask:(UIImage*)mask {
	
	CGImageRef imgRef = [image CGImage];
	CGImageRef maskRef = [mask CGImage];
	CGImageRef actualMask = CGImageMaskCreate(CGImageGetWidth(maskRef),
										CGImageGetHeight(maskRef),
										CGImageGetBitsPerComponent(maskRef),
										CGImageGetBitsPerPixel(maskRef),
										CGImageGetBytesPerRow(maskRef),
										CGImageGetDataProvider(maskRef), NULL, false);
	
	CGImageRef masked = CGImageCreateWithMask(imgRef, actualMask);
	
	return [UIImage imageWithCGImage:masked];
	
}</description>
		<content:encoded><![CDATA[<p>SOLUTION!!</p>
<p>Ok, this is stupidly easy to do after figuring out. The main problem is the mask image but after hours of banging my head on my desk I figured it out. Use whatever software you wish to create the mask.png with whatever colors you want and save it. The trick is to open it in Preview, yes Preview and click Save As, DESELECT the Alpha button and save. Your mask is now finished.</p>
<p>-(UIImage*)maskImage:(UIImage*)image withMask:(UIImage*)mask {</p>
<p>	CGImageRef imgRef = [image CGImage];<br />
	CGImageRef maskRef = [mask CGImage];<br />
	CGImageRef actualMask = CGImageMaskCreate(CGImageGetWidth(maskRef),<br />
										CGImageGetHeight(maskRef),<br />
										CGImageGetBitsPerComponent(maskRef),<br />
										CGImageGetBitsPerPixel(maskRef),<br />
										CGImageGetBytesPerRow(maskRef),<br />
										CGImageGetDataProvider(maskRef), NULL, false);</p>
<p>	CGImageRef masked = CGImageCreateWithMask(imgRef, actualMask);</p>
<p>	return [UIImage imageWithCGImage:masked];</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-10226</link>
		<dc:creator>John</dc:creator>
		<pubDate>Sun, 28 Feb 2010 18:59:10 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-10226</guid>
		<description>The code looks great, and I have made my mask.png file

However, where should I insert the code? My gues is system/library/coreservices/springboard.app/info.plist but I&#039;m not sure.

Also, would it automatically apply the mask to all apps? Thanks.</description>
		<content:encoded><![CDATA[<p>The code looks great, and I have made my mask.png file</p>
<p>However, where should I insert the code? My gues is system/library/coreservices/springboard.app/info.plist but I&#8217;m not sure.</p>
<p>Also, would it automatically apply the mask to all apps? Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryemac3</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-9845</link>
		<dc:creator>ryemac3</dc:creator>
		<pubDate>Sun, 21 Feb 2010 22:57:45 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-9845</guid>
		<description>So how do you can this method? Say your imageview is populated by the  &#039;didFinishPickingMediaWithInfo&quot; method, how would you mask the results? Do you just add this code to the &quot;didFinishPickingMediaWithInfo&quot; method?</description>
		<content:encoded><![CDATA[<p>So how do you can this method? Say your imageview is populated by the  &#8216;didFinishPickingMediaWithInfo&#8221; method, how would you mask the results? Do you just add this code to the &#8220;didFinishPickingMediaWithInfo&#8221; method?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-8715</link>
		<dc:creator>Jacob</dc:creator>
		<pubDate>Fri, 15 Jan 2010 16:18:46 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-8715</guid>
		<description>Great tips! I&#039;m having a bit of trouble though. I have a mask of a set size (100x100). I want to use this small mask on larger images of various sizes (320x480, 600x900, etc). However, my mask is stretching to the size of the image. Any ideas on how to maintain a smaller mask?

Thanks!</description>
		<content:encoded><![CDATA[<p>Great tips! I&#8217;m having a bit of trouble though. I have a mask of a set size (100&#215;100). I want to use this small mask on larger images of various sizes (320&#215;480, 600&#215;900, etc). However, my mask is stretching to the size of the image. Any ideas on how to maintain a smaller mask?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html/comment-page-1#comment-8201</link>
		<dc:creator>Amit</dc:creator>
		<pubDate>Mon, 28 Dec 2009 06:05:59 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1194#comment-8201</guid>
		<description>Hi ,

I am new to iphone development and dont know how to implement this concept in xcode for iphone ,can anybody please provide me the whole source code or sample project for image masking with image.

Thanks in Advance...</description>
		<content:encoded><![CDATA[<p>Hi ,</p>
<p>I am new to iphone development and dont know how to implement this concept in xcode for iphone ,can anybody please provide me the whole source code or sample project for image masking with image.</p>
<p>Thanks in Advance&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
