Author: manaRH
Date: 2013-04-29 10:37:22 -0400 (Mon, 29 Apr 2013)
New Revision: 15486
Modified:
branches/enterprise/JBPAPP_5_0/ui/src/main/java/org/jboss/seam/ui/graphicImage/Image.java
Log:
added a check for contentType if format is not supported
Modified:
branches/enterprise/JBPAPP_5_0/ui/src/main/java/org/jboss/seam/ui/graphicImage/Image.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/ui/src/main/java/org/jboss/seam/ui/graphicImage/Image.java 2013-04-24
10:14:08 UTC (rev 15485)
+++
branches/enterprise/JBPAPP_5_0/ui/src/main/java/org/jboss/seam/ui/graphicImage/Image.java 2013-04-29
14:37:22 UTC (rev 15486)
@@ -31,9 +31,9 @@
/**
* Image manipulation and interrogation
- *
+ *
* @author pmuir
- *
+ *
*/
@Name("org.jboss.seam.graphicImage.image")
@Install(precedence = Install.BUILT_IN)
@@ -44,7 +44,7 @@
public enum Type
{
IMAGE_PNG("image/png", ".png", "PNG"),
IMAGE_JPEG("image/jpeg", ".jpg", "JPEG",
"image/jpg"), IMAGE_GIF(
- "image/gif", ".gif", "GIF"),
IMAGE_BMP("image/bmp", ".bmp", "BMP");
+ "image/gif", ".gif", "GIF"),
IMAGE_BMP("image/bmp", ".bmp", "BMP");
private String mimeType;
@@ -109,7 +109,7 @@
}
public static final int PNG_IMAGE_TYPE = BufferedImage.TYPE_INT_ARGB;
-
+
public static final int DEFAULT_IMAGE_TYPE = BufferedImage.TYPE_INT_RGB;
private static final Type DEFAULT_CONTENT_TYPE = Type.IMAGE_PNG;
@@ -131,7 +131,7 @@
/**
* Set the image. This can be one of String (loaded from the classpath), a
* URL, a File, an InputStream or a byte[]
- *
+ *
* @param value
* @throws IOException
*/
@@ -148,7 +148,7 @@
*/
public byte[] getImage() throws IOException
{
- if ((dirty || output == null) && bufferedImage != null)
+ if ((dirty || output == null) && bufferedImage != null &&
getContentType() != null)
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ImageIO.write(bufferedImage, getContentType().getImageFormatName(),
outputStream);
@@ -169,12 +169,12 @@
{
this.contentType = contentType;
}
-
+
public BufferedImage getBufferedImage()
{
return bufferedImage;
}
-
+
public void setBufferedImage(BufferedImage bufferedImage)
{
this.bufferedImage = bufferedImage;
@@ -274,7 +274,7 @@
}
return this;
}
-
+
/**
* Blur the output image using a convolution
*/
@@ -284,8 +284,8 @@
return this;
}
BufferedImage newImage = new BufferedImage(getWidth(), getHeight(),
getImageType());
- int blurWidth = ((radius - 1) * 2 + 1);
- int pixels = blurWidth * blurWidth;
+ int blurWidth = ((radius - 1) * 2 + 1);
+ int pixels = blurWidth * blurWidth;
float weight = 1.0f/ pixels;
float[] elements = new float[pixels];
@@ -322,7 +322,7 @@
return this;
}
- public Image scaleToFit(int height, int width)
+ public Image scaleToFit(int height, int width)
throws IOException
{
float hratio = height/getHeight();
@@ -334,7 +334,7 @@
return scaleToWidth(width);
}
}
-
+
/**
* Scale the image to the given height
*/
@@ -354,11 +354,11 @@
dirty = true;
return this;
}
-
+
/**
* Scale the image by the given factor
*/
- public Image scale(double factor) throws IOException
+ public Image scale(double factor) throws IOException
{
if (bufferedImage == null)
{
@@ -373,12 +373,12 @@
dirty = true;
return this;
}
-
+
/**
* Resize the image to the given width and height, changing the ratio
* if necessary
*/
- public Image resize(int width, int height)
+ public Image resize(int width, int height)
{
if (bufferedImage == null)
{
@@ -422,7 +422,7 @@
/**
* Create Canvas, set some defaults (bg colour, rendering hints)
- *
+ *
* @param image
*/
private Graphics2D createGraphics(BufferedImage image)
@@ -481,7 +481,7 @@
dirty = true;
inputStream.close();
}
-
+
private int getImageType() {
if (Type.IMAGE_PNG.equals(getContentType()))
{