private void writeObject(ObjectOutputStream objectstream) throws IOException {
  objectstream.defaultWriteObject();
  PixelGrabber grabber=new PixelGrabber(bitmap,0,0,-1,-1,true);
  if (colorModel == COLORMODEL_IMAGEICON && bitmap != null) {
    try {
      grabber.grabPixels();
    }
 catch (    InterruptedException e) {
      logger.fine("error grabbing pixels");
    }
    Object pix=grabber.getPixels();
    Dimension dim=new Dimension(bitmap.getWidth(this),bitmap.getHeight(this));
    objectstream.writeObject(dim);
    objectstream.writeObject(pix);
  }
}

private void writeObject ( ObjectOutputStream objectstream ) throws IOException { objectstream . defaultWriteObject ( ) ; PixelGrabber grabber = new PixelGrabber ( bitmap , 0 , 0 , - 1 , - 1 , true ) ; if ( colorModel == COLORMODEL_IMAGEICON && bitmap != null ) { try { grabber . grabPixels ( ) ; } catch ( InterruptedException e ) { logger . fine ( "error grabbing pixels" ) ; } Object pix = grabber . getPixels ( ) ; Dimension dim = new Dimension ( bitmap . getWidth ( this ) , bitmap . getHeight ( this ) ) ; objectstream . writeObject ( dim ) ; objectstream . writeObject ( pix ) ; } }
code derived from http : / / www . dcs . shef . ac . uk / ~ tom / java / power / image_serialization . html
