You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pe...@apache.org on 2012/01/07 23:25:04 UTC
git commit: minor tweaks in ThumbnailImageResource
Updated Branches:
refs/heads/master bc7181809 -> bb687aa32
minor tweaks in ThumbnailImageResource
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/bb687aa3
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/bb687aa3
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/bb687aa3
Branch: refs/heads/master
Commit: bb687aa32ec3a8e5d21bb281c0301151afe7fc59
Parents: bc71818
Author: Peter Ertl <pe...@apache.org>
Authored: Sat Jan 7 23:21:37 2012 +0100
Committer: Peter Ertl <pe...@apache.org>
Committed: Sat Jan 7 23:21:37 2012 +0100
----------------------------------------------------------------------
.../image/resource/ThumbnailImageResource.java | 35 ++++++--------
1 files changed, 15 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/bb687aa3/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/image/resource/ThumbnailImageResource.java
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/image/resource/ThumbnailImageResource.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/image/resource/ThumbnailImageResource.java
index 7785046..36ebbe7 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/image/resource/ThumbnailImageResource.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/image/resource/ThumbnailImageResource.java
@@ -30,6 +30,7 @@ import org.apache.wicket.request.resource.DynamicImageResource;
import org.apache.wicket.request.resource.IResource;
import org.apache.wicket.response.ByteArrayResponse;
import org.apache.wicket.util.io.IOUtils;
+import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.time.Time;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,13 +70,8 @@ public class ThumbnailImageResource extends DynamicImageResource
*/
public ThumbnailImageResource(final IResource unscaledImageResource, final int maxSize)
{
- super();
-
- if (unscaledImageResource == null)
- {
- throw new IllegalArgumentException("Argument unscaledImageResource must be not null");
- }
-
+ Args.notNull(unscaledImageResource, "unscaledImageResource");
+
this.unscaledImageResource = unscaledImageResource;
this.maxSize = maxSize;
}
@@ -125,14 +121,7 @@ public class ThumbnailImageResource extends DynamicImageResource
}
finally
{
- try
- {
- IOUtils.close(is);
- }
- catch (IOException e)
- {
- log.error(e.getMessage(), e);
- }
+ IOUtils.closeQuietly(is);
}
int originalWidth = originalImage.getWidth();
@@ -157,11 +146,17 @@ public class ThumbnailImageResource extends DynamicImageResource
// http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
BufferedImage dimg = new BufferedImage(newWidth, newHeight, originalImage.getType());
Graphics2D g = dimg.createGraphics();
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g.drawImage(originalImage, 0, 0, newWidth, newHeight, 0, 0, originalWidth,
- originalHeight, null);
- g.dispose();
+ try
+ {
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+ g.drawImage(originalImage, 0, 0, newWidth, newHeight, 0, 0, originalWidth,
+ originalHeight, null);
+ }
+ finally
+ {
+ g.dispose();
+ }
return dimg;
}