<?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: Code Sample: Crop an image using the iPhone SDK</title>
	<atom:link href="http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/</link>
	<description>...hive05 is alive...</description>
	<lastBuildDate>Wed, 19 May 2010 20:05:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: sanket</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-1213</link>
		<dc:creator>sanket</dc:creator>
		<pubDate>Fri, 04 Dec 2009 08:49:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-1213</guid>
		<description>hello everyone,

Thanks for sharing code,that is really very helpful.
now we know that how to crop an image in rectangular shape.
but when i want to crop face or anything else rectangle may not help.

so my question is how to capture an image in oval or any other shape?
can we take pixel array for that?

any guidelines or help will be appreciated.</description>
		<content:encoded><![CDATA[<p>hello everyone,</p>
<p>Thanks for sharing code,that is really very helpful.<br />
now we know that how to crop an image in rectangular shape.<br />
but when i want to crop face or anything else rectangle may not help.</p>
<p>so my question is how to capture an image in oval or any other shape?<br />
can we take pixel array for that?</p>
<p>any guidelines or help will be appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-1081</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 13 Oct 2009 18:03:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-1081</guid>
		<description>This code causes a crash for me. I can easily reproduce it and I&#039;ve definitely narrowed it down to this code. When I take it out, the crash disappears. It may be the way I&#039;m using it, but I can&#039;t figure it out. The crash is caused by a double release. I copied and pasted this code into my app and then called it like so:

myImageView.image = [self imageByCropping:otherImageView.image toRect:CGRectMake(0, 0, 64, 64)];

I&#039;ve tried everything to debug it, but I can&#039;t figure it out. The debugger kindly suggests &quot;set a breakpoint in malloc_error_break to debug&quot; but that doesn&#039;t seem to help.</description>
		<content:encoded><![CDATA[<p>This code causes a crash for me. I can easily reproduce it and I&#8217;ve definitely narrowed it down to this code. When I take it out, the crash disappears. It may be the way I&#8217;m using it, but I can&#8217;t figure it out. The crash is caused by a double release. I copied and pasted this code into my app and then called it like so:</p>
<p>myImageView.image = [self imageByCropping:otherImageView.image toRect:CGRectMake(0, 0, 64, 64)];</p>
<p>I&#8217;ve tried everything to debug it, but I can&#8217;t figure it out. The debugger kindly suggests &#8220;set a breakpoint in malloc_error_break to debug&#8221; but that doesn&#8217;t seem to help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: calebhc</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-689</link>
		<dc:creator>calebhc</dc:creator>
		<pubDate>Sun, 30 Aug 2009 21:47:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-689</guid>
		<description>Hey HitScan, thanks for the code. It worked very nicely.</description>
		<content:encoded><![CDATA[<p>Hey HitScan, thanks for the code. It worked very nicely.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Generating UIImage Thumbnails &#8211; Scattered Focus</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-344</link>
		<dc:creator>Generating UIImage Thumbnails &#8211; Scattered Focus</dc:creator>
		<pubDate>Mon, 03 Aug 2009 20:26:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-344</guid>
		<description>[...] the thumbnail to be skewed so cropping was required. All of the examples I found either focused on cropping only or resizing but I couldn&#8217;t find any that did [...]</description>
		<content:encoded><![CDATA[<p>[...] the thumbnail to be skewed so cropping was required. All of the examples I found either focused on cropping only or resizing but I couldn&#8217;t find any that did [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shankins</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-61</link>
		<dc:creator>shankins</dc:creator>
		<pubDate>Fri, 24 Apr 2009 15:35:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-61</guid>
		<description>Wow, Thank you much for this code. Excellent.</description>
		<content:encoded><![CDATA[<p>Wow, Thank you much for this code. Excellent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HitScan</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-51</link>
		<dc:creator>HitScan</dc:creator>
		<pubDate>Fri, 03 Apr 2009 04:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-51</guid>
		<description>Actually there is a simple way to crop an image. Look up CGImageCreateWithImageInRect(CGImageRef, CGRect) in the documentation, it&#039;s pretty nice.

You could change the guts of imageByCropping:toRect: basically to this:

- (UIImage *)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect  {
  CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect); 
  UIImage *cropped = [UIImage imageWithCGImage:imageRef];
  CGImageRelease(imageRef);

   return cropped; 
}</description>
		<content:encoded><![CDATA[<p>Actually there is a simple way to crop an image. Look up CGImageCreateWithImageInRect(CGImageRef, CGRect) in the documentation, it&#8217;s pretty nice.</p>
<p>You could change the guts of imageByCropping:toRect: basically to this:</p>
<p>- (UIImage *)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect  {<br />
  CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect); <br />
  UIImage *cropped = [UIImage imageWithCGImage:imageRef];<br />
  CGImageRelease(imageRef);</p>
<p>   return cropped; <br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-42</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Fri, 13 Mar 2009 05:16:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-42</guid>
		<description>RuuD&#039;s code required a slight tweak for me when rect.origin wasn&#039;t at (0,0).  

CGContextTranslateCTM(currentContext, 0.0, rect.size.height);
CGContextScaleCTM(currentContext, 1.0, -1.0);

(rect.origin.x, rect.origin.y) are the coordinates from the lower-left corner of imageToCrop in its normal orientation.</description>
		<content:encoded><![CDATA[<p>RuuD&#8217;s code required a slight tweak for me when rect.origin wasn&#8217;t at (0,0).  </p>
<p>CGContextTranslateCTM(currentContext, 0.0, rect.size.height);<br />
CGContextScaleCTM(currentContext, 1.0, -1.0);</p>
<p>(rect.origin.x, rect.origin.y) are the coordinates from the lower-left corner of imageToCrop in its normal orientation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Capt. Bill</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-40</link>
		<dc:creator>Capt. Bill</dc:creator>
		<pubDate>Thu, 26 Feb 2009 18:07:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-40</guid>
		<description>Ahoy!

My hats off to ye!  A wonderful bit of code to share that worked like a charm.  It&#039;s rare to find such true copy/paste code that works this well.  I did have to implement the code RuuD posted to prevent the flippage but then all was well.

Thanks again, me hearty!</description>
		<content:encoded><![CDATA[<p>Ahoy!</p>
<p>My hats off to ye!  A wonderful bit of code to share that worked like a charm.  It&#8217;s rare to find such true copy/paste code that works this well.  I did have to implement the code RuuD posted to prevent the flippage but then all was well.</p>
<p>Thanks again, me hearty!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Image Slicing - iPhone Dev SDK Forum</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-31</link>
		<dc:creator>Image Slicing - iPhone Dev SDK Forum</dc:creator>
		<pubDate>Mon, 05 Jan 2009 08:00:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-31</guid>
		<description>[...] i did manage to make this work using   Code Sample: Crop an image using the iPhone SDK &#124; Hive05 software products  had to do some manipulations though. And one more important thing the 0,0 of the image is taken as [...]</description>
		<content:encoded><![CDATA[<p>[...] i did manage to make this work using   Code Sample: Crop an image using the iPhone SDK | Hive05 software products  had to do some manipulations though. And one more important thing the 0,0 of the image is taken as [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RuuD</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-30</link>
		<dc:creator>RuuD</dc:creator>
		<pubDate>Mon, 29 Dec 2008 12:06:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-30</guid>
		<description>Simply add these two lines just before the CGContextDrawImage line

CGContextTranslateCTM(currentContext, 0.0, drawRect.size.height);
CGContextScaleCTM(currentContext, 1.0, -1.0);

The result image was flip because Quartz start drawing from lower-left corner. (As stated in QuartzDemo sample code)</description>
		<content:encoded><![CDATA[<p>Simply add these two lines just before the CGContextDrawImage line</p>
<p>CGContextTranslateCTM(currentContext, 0.0, drawRect.size.height);<br />
CGContextScaleCTM(currentContext, 1.0, -1.0);</p>
<p>The result image was flip because Quartz start drawing from lower-left corner. (As stated in QuartzDemo sample code)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
