borland Packages  Class Hierarchy  jbcl.util Package  Index 

SerializableImage component

java.lang.Object
   +----borland.jbcl.util.SerializableImage

About the SerializableImage component

Variables  Constructors  Properties  Methods  

Implements Serializable

SerializableImage is a class that enables serialization of java.awt.Image objects.

Use this class when you need to save an image object into a serialized stream. When the image object is set, this class extracts the pixel information using a PixelGrabber, and the image is serialized as pixel data. When the image is deserialized, or retrieved, this class constructs a new MemoryImageSource object out of the saved pixel data.

The following is an example of reading and writing an Image data member from a class that implements java.io.Serializable.

// Image object marked as transient private transient Image image;
// Custom serialization support - save to stream private void
writeObject(ObjectOutputStream s) throws IOException {
    s.defaultWriteObject();
    s.writeObject(SerializableImage.create(image));
}

// Custom serialization support - load from stream
private void readObject(ObjectInputStream s) throws IOException,
    ClassNotFoundException { s.defaultReadObject();
    image = ((SerializableImage)s.readObject()).getImage();
} 

SerializableImage variables

Variables implemented in this class

SerializableImage constructors

SerializableImage properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.lang.Object

SerializableImage methods

Methods implemented in this class

Methods implemented in java.lang.Object


SerializableImage variables

image

  protected transient Image image

imageData

  protected int[] imageData

imageHeight

  protected int imageHeight

imageWidth

  protected int imageWidth

SerializableImage constructors

SerializableImage()

  public SerializableImage()
Constructs a SerializableImage object with no associated java.awt.Image object.

See Also: setImage

SerializableImage(java.awt.Image)

  public SerializableImage(java.awt.Image image)
Constructs a SerializableImage object with the passed java.awt.Image object.

Parameters:

image
the associated java.awt.Image object.

SerializableImage properties

image

 public Image getImage()
 public void setImage(java.awt.Image image)
The image property defines the java.awt.Image object that is to be serialized with this class.

SerializableImage methods

create(java.awt.Image)

  public static final SerializableImage create(java.awt.Image source)
If the Image specified with the source parameter exists, this method attempts to create a SerializableImage by calling the SerializableImage constructor, passing to it the source Image. create returns the SerializableImage.