[Title] common-eplugin: fixed non-scaled image problem for new wizard
authorJihoon Song <jihoon80.song@samsung.com>
Thu, 26 Sep 2013 06:53:18 +0000 (15:53 +0900)
committerJihoon Song <jihoon80.song@samsung.com>
Thu, 26 Sep 2013 07:45:28 +0000 (16:45 +0900)
[Desc.]
[Issue] N_SE-52811

Change-Id: I2406b548b94e333db28c8c0693f1f0dfacbd5db7

org.tizen.common.ui/src/org/tizen/common/ui/wizards/TizenCommonPWComposite.java
org.tizen.common/src/org/tizen/common/util/ImageUtil.java

index 4fc2f67..75004da 100644 (file)
@@ -78,6 +78,7 @@ public class TizenCommonPWComposite extends PWWidget {
     private int TREEVIEWER_WIDTH = 200;\r
     private int BROWSER_WIDTH = 418;\r
     private int ICON_WIDTH = 40;\r
+    private int ICON_DEFAULT_SIZE = 32;\r
     final int TEXT_MARGIN = 30;\r
 \r
     protected TizenCommonPWComposite(Category root, TizenCommonWizardPage page, String label, String propertyKey, int numberOfColumns, boolean singleWidget) {\r
@@ -197,7 +198,12 @@ public class TizenCommonPWComposite extends PWWidget {
         viewerColumnIcon.setLabelProvider(new ColumnLabelProvider() {\r
             @Override\r
             public Image getImage(Object element) {\r
-                return TizenCommonPWComposite.this.getImage(element);\r
+                Image image = TizenCommonPWComposite.this.getImage( element );\r
+                try {\r
+                    return ImageUtil.getSimpleScaledSWTImage( image, ICON_DEFAULT_SIZE, ICON_DEFAULT_SIZE );\r
+                } finally {\r
+                    SWTUtil.tryDispose( image );\r
+                }\r
             }\r
 \r
             @Override\r
index 5395ba1..3349c61 100644 (file)
@@ -227,7 +227,32 @@ public class ImageUtil {
 
         return scaledImage;
     }
-
+    
+    /**
+     * Returns a copy of the receiver which has been stretched or shrunk to the specified size.<br>
+     * If either the width or height is negative, the resulting image will be inverted in the associated axis.
+     * @param src the Image to use as the source
+     * @param width the width of the new Image
+     * @param height the height of the new Image
+     * @return a scaled copy of the image
+     */
+    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 ) {
+                // use the original data for performance
+                scaledImage = new Image( src.getDevice(), src, SWT.IMAGE_COPY );
+            } else {
+                // use the scaled data
+                scaledImage = new Image( src.getDevice(), srcData.scaledTo( width, height ) );
+            }
+        }
+        
+        return scaledImage;
+    }
+    
     public static Image convertImageToSWT(Display display, BufferedImage bImage) {
         int width = bImage.getWidth();
         int height = bImage.getHeight();