diff --git a/src/helma/image/IRemoteImage.java b/src/helma/image/IRemoteImage.java index 1e57ae90..ac308315 100644 --- a/src/helma/image/IRemoteImage.java +++ b/src/helma/image/IRemoteImage.java @@ -16,6 +16,7 @@ public interface IRemoteImage extends Remote { public void setFont (String name, int style, int size) throws RemoteException; public void setColor (int color) throws RemoteException; public void setColor (int r, int g, int b) throws RemoteException; + public void reduceColors (int colors) throws RemoteException; public void drawString (String str, int x, int y) throws RemoteException; @@ -29,9 +30,5 @@ public interface IRemoteImage extends Remote { public void resize (int w, int h) throws RemoteException; public void saveAs (String filename) throws RemoteException; - public void readFrom (String filename) throws RemoteException; - - public byte[] getBytes (String type) throws RemoteException; - public void setBytes (byte[] bytes, String type) throws RemoteException; -} \ No newline at end of file +} diff --git a/src/helma/image/ImageGenerator.java b/src/helma/image/ImageGenerator.java index 0afa35da..ff6dadb5 100644 --- a/src/helma/image/ImageGenerator.java +++ b/src/helma/image/ImageGenerator.java @@ -4,6 +4,7 @@ package helma.image; import java.awt.*; +import java.awt.image.*; import java.net.URL; /** @@ -117,7 +118,32 @@ public class ImageGenerator extends Window { } return rimg; } - + + public ImageWrapper createPaintableImage (ImageWrapper iw, ImageFilter filter) { + ImageWrapper rimg = null; + MediaTracker tracker = new MediaTracker (this); + try { + FilteredImageSource fis = new FilteredImageSource (iw.getSource(), filter); + Image img1 = createImage (fis); + tracker.addImage (img1, 0); + tracker.waitForAll (); + int w = img1.getWidth (null); + int h = img1.getHeight (null); + Image img = createImage (w, h); + Graphics g = img.getGraphics (); + g.drawImage (img1, 0, 0, null); + try { + rimg = new ActivatedImageWrapper (img, g, w, h, this); + } catch (NoClassDefFoundError notfound) { + rimg = new SunImageWrapper (img, g, w, h, this); + } catch (ClassNotFoundException notfound) { + rimg = new SunImageWrapper (img, g, w, h, this); + } + } catch (Exception x) {} + return rimg; + } + + public Image createImage (String filename) { Image img = null; MediaTracker tracker = new MediaTracker (this); diff --git a/src/helma/image/ImageWrapper.java b/src/helma/image/ImageWrapper.java index bd236a5f..0740051d 100644 --- a/src/helma/image/ImageWrapper.java +++ b/src/helma/image/ImageWrapper.java @@ -102,16 +102,11 @@ public abstract class ImageWrapper { public abstract void saveAs (String filename); - public void readFrom (String filename) { - throw new RuntimeException ("Image.readFrom() is currently not implemented."); - } - - public byte[] getBytes (String type) { - throw new RuntimeException ("Image.getBytes() is currently not implemented."); - } - - public void setBytes (byte[] bytes, String type) { - throw new RuntimeException ("Image.setBytes() is currently not implemented."); + /** + * Get ImageProducer of the wrapped image + */ + public ImageProducer getSource () { + return img.getSource (); } public void fillString (String str) { diff --git a/src/helma/image/RemoteImage.java b/src/helma/image/RemoteImage.java index dff899e3..1623c6d2 100644 --- a/src/helma/image/RemoteImage.java +++ b/src/helma/image/RemoteImage.java @@ -77,18 +77,6 @@ public class RemoteImage extends UnicastRemoteObject implements IRemoteImage { wrapped.saveAs (filename); } - public void readFrom (String filename) { - wrapped.readFrom (filename); - } - - public byte[] getBytes (String type) { - return wrapped.getBytes (type); - } - - public void setBytes (byte[] bytes, String type) { - wrapped.setBytes (bytes, type); - } - public void fillString (String str) { wrapped.fillString (str); }