diff options
author | changhyun1.lee <changhyun1.lee@samsung.com> | 2014-08-04 19:39:07 +0900 |
---|---|---|
committer | changhyun1.lee <changhyun1.lee@samsung.com> | 2014-08-04 19:40:34 +0900 |
commit | c0677aad6d0a52cd3936fce919d70d8ecd5991dd (patch) | |
tree | a1e16fff4c14195cc263b4674101d17e200d3e2b | |
parent | b6c21c654989197877c872e6bdd90712320afe3e (diff) | |
download | common-eplugin-c0677aad6d0a52cd3936fce919d70d8ecd5991dd.tar.gz common-eplugin-c0677aad6d0a52cd3936fce919d70d8ecd5991dd.tar.bz2 common-eplugin-c0677aad6d0a52cd3936fce919d70d8ecd5991dd.zip |
COMMON: Fixed image handler
Change-Id: I11adc2af949f6b1ac8f4a4f4517df16b917a7978
Signed-off-by: changhyun1.lee <changhyun1.lee@samsung.com>
-rw-r--r-- | org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java | 6 | ||||
-rw-r--r-- | org.tizen.common/src/org/tizen/common/util/ImageUtil.java | 65 |
2 files changed, 38 insertions, 33 deletions
diff --git a/org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java b/org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java index 33d0ca81c..035152bed 100644 --- a/org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java +++ b/org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java @@ -293,9 +293,13 @@ public class NewIconDialog extends SelectionStatusDialog { } else if (iconExtension.equalsIgnoreCase(BMP)) { BMPEncoder.write(ImageUtil.convertToAWT(image.getImageData()), new File(destFilePath)); } else { + int imageFormat = SWT.IMAGE_PNG; + if ( iconExtension.equalsIgnoreCase(JPG) || iconExtension.equalsIgnoreCase(JPEG) ) { + imageFormat = SWT.IMAGE_JPEG; + } ImageLoader loader = new ImageLoader(); loader.data = new ImageData[] { image.getImageData() }; - loader.save(destFilePath, SWT.IMAGE_PNG); + loader.save(destFilePath, imageFormat); } } else { if (!fPath.equals(destFilePath)) { diff --git a/org.tizen.common/src/org/tizen/common/util/ImageUtil.java b/org.tizen.common/src/org/tizen/common/util/ImageUtil.java index d4d2307c3..b9003e5b7 100644 --- a/org.tizen.common/src/org/tizen/common/util/ImageUtil.java +++ b/org.tizen.common/src/org/tizen/common/util/ImageUtil.java @@ -107,6 +107,8 @@ public class ImageUtil { public static final String ICO = "ico"; //$NON-NLS-1$ public static final String BMP = "bmp"; //$NON-NLS-1$ public static final String SVG = "svg"; //$NON-NLS-1$ + public static final String JPG = "jpg"; //$NON-NLS-1$ + public static final String JPEG = "jpeg"; //$NON-NLS-1$ /** * load image descriptor from <code>bundle</code> with <code>filePath</code> @@ -255,36 +257,37 @@ public class ImageUtil { public static List<BufferedImage> getAWTImages(InputStream is, String iconFilePath) throws IOException { List<BufferedImage> images = new ArrayList<BufferedImage>(); String formatName = getFormatName(iconFilePath); - if (formatName.equalsIgnoreCase(ICO)) { - images = ICODecoder.read(is); - } else if (formatName.equalsIgnoreCase(BMP)) { - images.add(BMPDecoder.read(is)); - } else if (formatName.equalsIgnoreCase(SVG)) { - SVGUniverse svgUnverse = new SVGUniverse(); - URI iconUri = svgUnverse.loadSVG(is, formatName); - if (iconUri == null) { - return images; - } - SVGDiagram diagram = svgUnverse.getDiagram(iconUri); - if (diagram == null) { - return images; - } - BufferedImage image = new BufferedImage((int)diagram.getWidth(), (int)diagram.getHeight(), BufferedImage.TYPE_INT_ARGB); - Graphics2D graphics = null; - try { - graphics = image.createGraphics(); - diagram.render(graphics); - images.add(image); - } catch (SVGException e) { - throw new IOException(e); - } finally { - if ( graphics != null ) { graphics.dispose(); } + if ( !StringUtil.isEmpty(formatName) ) { + if (formatName.equalsIgnoreCase(ICO)) { + images = ICODecoder.read(is); + } else if (formatName.equalsIgnoreCase(BMP)) { + images.add(BMPDecoder.read(is)); + } else if (formatName.equalsIgnoreCase(SVG)) { + SVGUniverse svgUnverse = new SVGUniverse(); + URI iconUri = svgUnverse.loadSVG(is, formatName); + if (iconUri == null) { + return images; + } + SVGDiagram diagram = svgUnverse.getDiagram(iconUri); + if (diagram == null) { + return images; + } + BufferedImage image = new BufferedImage((int)diagram.getWidth(), (int)diagram.getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D graphics = null; + try { + graphics = image.createGraphics(); + diagram.render(graphics); + images.add(image); + } catch (SVGException e) { + throw new IOException(e); + } finally { + if ( graphics != null ) { graphics.dispose(); } + } + } else { + // CAUTION: numbers of source Raster bands and source color space components do not match" bug. + images.add(ImageIO.read(is)); } - } else { - // CAUTION: numbers of source Raster bands and source color space components do not match" bug. - images.add(ImageIO.read(is)); } - return images; } @@ -413,7 +416,6 @@ public class ImageUtil { */ public static Image getSimpleScaledSWTImage(Image src, int width, int height) { Image scaledImage = null; - if ( src != null ) { ImageData srcData = src.getImageData(); if ( srcData.width == width && srcData.height == height ) { @@ -424,7 +426,6 @@ public class ImageUtil { scaledImage = new Image( src.getDevice(), srcData.scaledTo( width, height ) ); } } - return scaledImage; } @@ -581,7 +582,7 @@ public class ImageUtil { /** * Writes <code>BufferedImage</code> to <code>OutputStream</code>. * @param bImg <code>BufferedImage</code> - * @param formatName + * @param formatName * @param os <code>OutputStream</code> * @throws IOException */ @@ -591,7 +592,7 @@ public class ImageUtil { } else if (BMP.equalsIgnoreCase(formatName)) { BMPEncoder.write(bImg, os); } else if (SVG.equalsIgnoreCase(formatName)) { - //TODO: + // INFO:: Don't support svg format } else { ImageIO.write(bImg, formatName, os); } |