Revision: 4500
          http://vexi.svn.sourceforge.net/vexi/?rev=4500&view=rev
Author:   clrg
Date:     2013-03-22 03:16:36 +0000 (Fri, 22 Mar 2013)
Log Message:
-----------
Feature.  Smooth image scaling.

Modified Paths:
--------------
    trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java
    trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java
    trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java
    trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java

Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java
===================================================================
--- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java       
2013-03-21 09:19:44 UTC (rev 4499)
+++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java       
2013-03-22 03:16:36 UTC (rev 4500)
@@ -270,10 +270,9 @@
                // dirty() is implicit due to SizeChange
                //dirty();
             }
-            buf.g = buf.i.getGraphics();
+            buf.initGraphics();
             RenderedRegions r = super.render();
-            buf.g.dispose();
-            buf.g = null;
+            buf.cleanupGraphics();
             if (r==null) {
                 if (blithack) {
                     blithack = false;

Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java
===================================================================
--- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java   
2013-03-21 09:19:44 UTC (rev 4499)
+++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java   
2013-03-22 03:16:36 UTC (rev 4500)
@@ -15,6 +15,7 @@
 import java.awt.FileDialog;
 import java.awt.Frame;
 import java.awt.Graphics;
+import java.awt.Graphics2D;
 import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsEnvironment;
 import java.awt.Image;
@@ -22,6 +23,7 @@
 import java.awt.MediaTracker;
 import java.awt.Point;
 import java.awt.Rectangle;
+import java.awt.RenderingHints;
 import java.awt.TextArea;
 import java.awt.Toolkit;
 import java.awt.Window;
@@ -50,11 +52,13 @@
 import java.awt.image.MemoryImageSource;
 import java.awt.image.PixelGrabber;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 
 import javax.swing.ImageIcon;
 
 import org.ibex.js.JS;
+import org.ibex.js.JSExn;
 import org.ibex.util.Callable;
 import org.ibex.util.IOUtil;
 import org.ibex.util.Semaphore;
@@ -275,7 +279,7 @@
     protected static class AWTPixelBuffer implements PixelBuffer {
         
         protected Image i = null;
-        protected Graphics g = null;
+        protected Graphics2D g = null;
         protected AWTSurface surface = null;
         
         /** JDK1.1 platforms require that a component be associated with each 
off-screen buffer */
@@ -290,10 +294,17 @@
             }
         }
 
+        protected void initGraphics() {
+            g = (Graphics2D)i.getGraphics();
+            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+        }
+        protected void cleanupGraphics() {
+            g.dispose();
+            g = null;
+        }
         public AWTPixelBuffer() { }
         public AWTPixelBuffer(Image i) {
             this.i = i;
-            g = i.getGraphics();
         }
         public AWTPixelBuffer(AWTSurface s) {
             this(Platform.getScreenBounds().width, 
Platform.getScreenBounds().height);
@@ -306,7 +317,6 @@
         public AWTPixelBuffer(int w, int h) {
             setupComponent();
             i = component.createImage(w, h);
-            g = i.getGraphics();
         }
         
         public int getHeight() { return i == null ? 0 : i.getHeight(null); }
@@ -601,10 +611,9 @@
                // dirty() is implicit due to SizeChange
                //dirty();
             }
-            buf.g = buf.i.getGraphics();
+            buf.initGraphics();
             RenderedRegions r = super.render();
-            buf.g.dispose();
-            buf.g = null;
+            buf.cleanupGraphics();
             if (r==null) {
                 if (blithack) {
                     blithack = false;

Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java
===================================================================
--- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java     
2013-03-21 09:19:44 UTC (rev 4499)
+++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java     
2013-03-22 03:16:36 UTC (rev 4500)
@@ -288,7 +288,6 @@
             }
             raster = Raster.createWritableRaster(sm, buf, null);
             i = new BufferedImage(cm, raster, false,  emptyHashtable);
-            g = i.getGraphics();
         }
     }
 

Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java
===================================================================
--- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java     
2013-03-21 09:19:44 UTC (rev 4499)
+++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java     
2013-03-22 03:16:36 UTC (rev 4500)
@@ -449,7 +449,7 @@
                     ((InnerPanel)panel).resetBuffer();
                 }
 
-                buf.g = buf.i.getGraphics();
+                buf.initGraphics();
                 if (pendingWidth < root.width || pendingHeight < root.height) {
                     buf.g.setColor(rootcolor);
                     if (pendingWidth < root.width) {
@@ -460,8 +460,7 @@
                     }
                 }
                 r = super.render();
-                buf.g.dispose();
-                buf.g = null;
+                buf.cleanupGraphics();
 
                 if (r==null) {
                     return null;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to