<?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: Java Bicubic Image Resizing</title>
	<atom:link href="http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/</link>
	<description>Java, PHP, Photoshop, tutorials, MSN Addins, Open Source,</description>
	<lastBuildDate>Tue, 31 Jan 2012 02:11:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Elie</title>
		<link>http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/#comment-43990</link>
		<dc:creator>Elie</dc:creator>
		<pubDate>Tue, 04 Nov 2008 23:13:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.ekhoury.com/2006/09/07/java-bicubic-image-resizing/#comment-43990</guid>
		<description>@David,

You can always resize images with any software, but some developers need to create softwares like piknic! This is what&#039;s this tip is all about...</description>
		<content:encoded><![CDATA[<p>@David,</p>
<p>You can always resize images with any software, but some developers need to create softwares like piknic! This is what&#8217;s this tip is all about&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David J Carne</title>
		<link>http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/#comment-43981</link>
		<dc:creator>David J Carne</dc:creator>
		<pubDate>Tue, 04 Nov 2008 20:58:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.ekhoury.com/2006/09/07/java-bicubic-image-resizing/#comment-43981</guid>
		<description>Sorry if I  sound a bit simplistic but for resizeing images I always use picnik . com  works for me</description>
		<content:encoded><![CDATA[<p>Sorry if I  sound a bit simplistic but for resizeing images I always use picnik . com  works for me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: whe</title>
		<link>http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/#comment-31248</link>
		<dc:creator>whe</dc:creator>
		<pubDate>Fri, 20 Jun 2008 13:33:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.ekhoury.com/2006/09/07/java-bicubic-image-resizing/#comment-31248</guid>
		<description>Hi,

I&#039;ve given the above algorithm to one of our developers

BufferedImage temp = javax.imageio.ImageIO.read(new File(imagefile));
/* determine thumbnail size from WIDTH and HEIGHT */
int thumbWidth = width;
int thumbHeight = height;
int imageWidth = temp.getWidth(null);
int imageHeight = temp.getHeight(null);

int tempWidth;
int tempHeight;
int x = 0;
int y = 0;

if (imageWidth &lt; imageHeight) {
    tempWidth = width;
    tempHeight = (int)(((double)imageHeight*width)/imageWidth);
    y = -(tempHeight - tempWidth)/2;
}
else {
    tempHeight = height;
    tempWidth = (int)(((double)imageWidth*height)/imageHeight);
    x = -(tempWidth - tempHeight)/2;
}
Image temp1 = temp.getScaledInstance(tempWidth, tempHeight, Image.SCALE_SMOOTH);
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
image.getGraphics().drawImage(temp1, x, y, null);
try {
    javax.imageio.ImageIO.write(image, &quot;png&quot;, new File(&quot;output.png&quot;));
} catch (IOException e) {
    e.printStackTrace();
}

But he says

but the ImageIO does not recognize a number of images uploaded by the dealer. It seems to have problems with non-standard colour palettes. This is something we saw frequently in production untill we switched to the current method with the toolkit.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;ve given the above algorithm to one of our developers</p>
<p>BufferedImage temp = javax.imageio.ImageIO.read(new File(imagefile));<br />
/* determine thumbnail size from WIDTH and HEIGHT */<br />
int thumbWidth = width;<br />
int thumbHeight = height;<br />
int imageWidth = temp.getWidth(null);<br />
int imageHeight = temp.getHeight(null);</p>
<p>int tempWidth;<br />
int tempHeight;<br />
int x = 0;<br />
int y = 0;</p>
<p>if (imageWidth &lt; imageHeight) {<br />
    tempWidth = width;<br />
    tempHeight = (int)(((double)imageHeight*width)/imageWidth);<br />
    y = -(tempHeight &#8211; tempWidth)/2;<br />
}<br />
else {<br />
    tempHeight = height;<br />
    tempWidth = (int)(((double)imageWidth*height)/imageHeight);<br />
    x = -(tempWidth &#8211; tempHeight)/2;<br />
}<br />
Image temp1 = temp.getScaledInstance(tempWidth, tempHeight, Image.SCALE_SMOOTH);<br />
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);<br />
image.getGraphics().drawImage(temp1, x, y, null);<br />
try {<br />
    javax.imageio.ImageIO.write(image, &#8220;png&#8221;, new File(&#8220;output.png&#8221;));<br />
} catch (IOException e) {<br />
    e.printStackTrace();<br />
}</p>
<p>But he says</p>
<p>but the ImageIO does not recognize a number of images uploaded by the dealer. It seems to have problems with non-standard colour palettes. This is something we saw frequently in production untill we switched to the current method with the toolkit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pcs</title>
		<link>http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/#comment-22276</link>
		<dc:creator>pcs</dc:creator>
		<pubDate>Tue, 04 Mar 2008 06:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.ekhoury.com/2006/09/07/java-bicubic-image-resizing/#comment-22276</guid>
		<description>Graphics2D g2 = (Graphics2D)g;
					AffineTransform at = AffineTransform.getScaleInstance(1.5, 1.5);
					AffineTransformOp aop =	new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
					g2.drawImage(image, aop, 0, 0);</description>
		<content:encoded><![CDATA[<p>Graphics2D g2 = (Graphics2D)g;<br />
					AffineTransform at = AffineTransform.getScaleInstance(1.5, 1.5);<br />
					AffineTransformOp aop =	new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);<br />
					g2.drawImage(image, aop, 0, 0);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pcs</title>
		<link>http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/#comment-22275</link>
		<dc:creator>pcs</dc:creator>
		<pubDate>Tue, 04 Mar 2008 06:49:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.ekhoury.com/2006/09/07/java-bicubic-image-resizing/#comment-22275</guid>
		<description>use this code
where image is BufferedImage object
Graphics2D g2 = (Graphics2D)g;
AffineTransform at = AffineTransform.getScaleInstance(1.5, 1.5);
AffineTransformOp aop =	new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
g2.drawImage(image, aop, 0, 0);</description>
		<content:encoded><![CDATA[<p>use this code<br />
where image is BufferedImage object<br />
Graphics2D g2 = (Graphics2D)g;<br />
AffineTransform at = AffineTransform.getScaleInstance(1.5, 1.5);<br />
AffineTransformOp aop =	new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);<br />
g2.drawImage(image, aop, 0, 0);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Negora</title>
		<link>http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/#comment-865</link>
		<dc:creator>Negora</dc:creator>
		<pubDate>Sun, 07 Jan 2007 16:35:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.ekhoury.com/2006/09/07/java-bicubic-image-resizing/#comment-865</guid>
		<description>I&#039;ve found this page while I was looking for some information on Google, so this answer arrives a little late... Anyway, I&#039;ve realized that you suffered the same problem which I did weeks ago, when I was developing an image manipulator for the enterprise where I work.

After reading many documents (althought only one gave a good clue to fix it), I came to the conclusion that the Java 2D library doesn&#039;t work well when you down-resize from very distant sizes. Aproximately when the scale proportion is below the 50% of the image size. If you apply a progressive resizing (by steps), you get a nice and smooth result. I made a recursive function and it worked.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve found this page while I was looking for some information on Google, so this answer arrives a little late&#8230; Anyway, I&#8217;ve realized that you suffered the same problem which I did weeks ago, when I was developing an image manipulator for the enterprise where I work.</p>
<p>After reading many documents (althought only one gave a good clue to fix it), I came to the conclusion that the Java 2D library doesn&#8217;t work well when you down-resize from very distant sizes. Aproximately when the scale proportion is below the 50% of the image size. If you apply a progressive resizing (by steps), you get a nice and smooth result. I made a recursive function and it worked.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danack</title>
		<link>http://www.ekhoury.com/blog/2006/09/07/java-bicubic-image-resizing/#comment-170</link>
		<dc:creator>Danack</dc:creator>
		<pubDate>Fri, 10 Nov 2006 10:05:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.ekhoury.com/2006/09/07/java-bicubic-image-resizing/#comment-170</guid>
		<description>Thanks - btw the bicubic &#039;hint&#039; should be actually implemented in Java 1.5. However it doesn&#039;t appear to be working. I believe the code below should do a bicubic transform, but it doesn&#039;t.

BufferedImage source, target...;


        double scalex = (double) target.getWidth() / source.getWidth();
        double scaley = (double) target.getHeight() / source.getHeight();
        AffineTransform at = AffineTransform.getScaleInstance(scalex, scaley);

        AffineTransformOp affineTransformOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);

        affineTransformOp.filter(source, target);</description>
		<content:encoded><![CDATA[<p>Thanks &#8211; btw the bicubic &#8216;hint&#8217; should be actually implemented in Java 1.5. However it doesn&#8217;t appear to be working. I believe the code below should do a bicubic transform, but it doesn&#8217;t.</p>
<p>BufferedImage source, target&#8230;;</p>
<p>        double scalex = (double) target.getWidth() / source.getWidth();<br />
        double scaley = (double) target.getHeight() / source.getHeight();<br />
        AffineTransform at = AffineTransform.getScaleInstance(scalex, scaley);</p>
<p>        AffineTransformOp affineTransformOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);</p>
<p>        affineTransformOp.filter(source, target);</p>
]]></content:encoded>
	</item>
</channel>
</rss>

