<?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>Fri, 24 Jun 2011 05:28:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: freenoiz</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-2848</link>
		<dc:creator>freenoiz</dc:creator>
		<pubDate>Thu, 14 Oct 2010 10:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-2848</guid>
		<description>Hi

@sanket - Have you found how to capture an image in other shapes not rectangular ?

Thanks for your help.</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>@sanket &#8211; Have you found how to capture an image in other shapes not rectangular ?</p>
<p>Thanks for your help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Cheng</title>
		<link>http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/comment-page-1/#comment-2302</link>
		<dc:creator>Frank Cheng</dc:creator>
		<pubDate>Fri, 16 Apr 2010 04:58:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.hive05.com/?p=113#comment-2302</guid>
		<description>I am trying to display a view which combines the first half of image1.png and the second half of image2.png. Please help me with some sample codes. Frank</description>
		<content:encoded><![CDATA[<p>I am trying to display a view which combines the first half of image1.png and the second half of image2.png. Please help me with some sample codes. Frank</p>
]]></content:encoded>
	</item>
	<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>
</channel>
</rss>

