488 } |
488 } |
489 |
489 |
490 private void readObject(ObjectInputStream s) |
490 private void readObject(ObjectInputStream s) |
491 throws ClassNotFoundException, IOException |
491 throws ClassNotFoundException, IOException |
492 { |
492 { |
493 s.defaultReadObject(); |
493 ObjectInputStream.GetField f = s.readFields(); |
|
494 |
|
495 imageObserver = (ImageObserver) f.get("imageObserver", null); |
|
496 description = (String) f.get("description", null); |
|
497 width = f.get("width", -1); |
|
498 height = f.get("height", -1); |
|
499 accessibleContext = (AccessibleImageIcon) f.get("accessibleContext", null); |
494 |
500 |
495 int w = s.readInt(); |
501 int w = s.readInt(); |
496 int h = s.readInt(); |
502 int h = s.readInt(); |
497 int[] pixels = (int[])(s.readObject()); |
503 int[] pixels = (int[])(s.readObject()); |
|
504 |
|
505 if (pixels == null && (w != -1 || h != -1)) { |
|
506 throw new IllegalStateException("Inconsistent width and height" |
|
507 + " for null image [" + w + ", " + h + "]"); |
|
508 } |
|
509 |
|
510 if (pixels != null && (w < 0 || h < 0)) { |
|
511 throw new IllegalStateException("Inconsistent width and height" |
|
512 + " for image [" + w + ", " + h + "]"); |
|
513 } |
|
514 |
|
515 if (w != getIconWidth() || h != getIconHeight()) { |
|
516 throw new IllegalStateException("Inconsistent width and height" |
|
517 + " for image [" + w + ", " + h + "]"); |
|
518 } |
498 |
519 |
499 if (pixels != null) { |
520 if (pixels != null) { |
500 Toolkit tk = Toolkit.getDefaultToolkit(); |
521 Toolkit tk = Toolkit.getDefaultToolkit(); |
501 ColorModel cm = ColorModel.getRGBdefault(); |
522 ColorModel cm = ColorModel.getRGBdefault(); |
502 image = tk.createImage(new MemoryImageSource(w, h, cm, pixels, 0, w)); |
523 image = tk.createImage(new MemoryImageSource(w, h, cm, pixels, 0, w)); |