/** * Constructs an <code>EncodedImageReference</code> with an image. * * @param image A java.awt.Image to be displayed. If you intend to extend this class and override * the getImage() method to return images only as they are needed, then you may pass null to * this parameter. */ public EncodedImageReference(Image image) { this.internalImage = image; if (image != null && ImageKit.hasAlphaChannel(image)) encoder = new GifEncoder(); else encoder = new PngEncoder(); refEncodedBytes = new SoftReference(null); keptInMemory = false; valid = false; }
/** @see java.io.Serializable */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); Class encoderClass = (Class) in.readObject(); try { encoder = (ImageEncoder) encoderClass.newInstance(); } catch (Exception e) { throw new IOException( "Unable to instanstiate the encoder class : " + encoderClass.getName() + " : " + e.toString()); } valid = false; refEncodedBytes = new SoftReference(null); this.internalImage = ImageKit.readSerializedImage(in); }
/** @see java.io.Serializable */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeObject(encoder.getClass()); ImageKit.writeSerializedImage(out, getImage()); }