diff options
| author | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-04-17 03:43:11 +0000 |
|---|---|---|
| committer | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-04-17 03:43:11 +0000 |
| commit | 58d9f5e31a26415fe1c7d8106fcb4a724bbe81cd (patch) | |
| tree | 8232030a4bb683ff07e84cd2eeb4906c04beabc0 /java/ImageProcessing/framework | |
| parent | 91583e8596d11df16bc8606d0a9cfd11711d1207 (diff) | |
| download | ATCD-58d9f5e31a26415fe1c7d8106fcb4a724bbe81cd.tar.gz | |
Moved the caching of the image after the image gets loaded.
Diffstat (limited to 'java/ImageProcessing/framework')
| -rw-r--r-- | java/ImageProcessing/framework/ImageCanvas.java | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/java/ImageProcessing/framework/ImageCanvas.java b/java/ImageProcessing/framework/ImageCanvas.java index d334be45ef4..a2048160359 100644 --- a/java/ImageProcessing/framework/ImageCanvas.java +++ b/java/ImageProcessing/framework/ImageCanvas.java @@ -3,29 +3,47 @@ package imaging.framework; import java.awt.*; import java.awt.image.*; import gjt.Util; +import JACE.OS.*; class ImageCanvas extends Canvas { public static final double MAX_ZOOM = 4.0; public static final double MIN_ZOOM = 0.5; - public void setImage (Image image) + public int setImage (Image image) { + int flags = 0; if (image != null) { - this.image_ = image; - this.originalImage_ = this.image_; - // Load the image - this.tracker_.addImage(this.image_, 0); + this.tracker_.addImage(image, 0); try { this.tracker_.waitForID(0); } catch(InterruptedException excp) {} + if (this.tracker_.isErrorAny ()) + System.out.println ("Error"); + // Check if the image was actually loaded. Note that we have + // to wait for the potential image to finish loading before we + // know if it is a valid image. + flags = this.checkImage (image, this); + if (ACE.BIT_ENABLED (flags, ImageObserver.ERROR)) + return -1; + + // If we reached here, it means image was loaded successfully so cache it + this.image_ = image; + this.originalImage_ = this.image_; + this.x_ = (this.size ().width - this.image_.getWidth (this))/2; this.y_ = (this.size ().height - this.image_.getHeight (this))/2; this.original_x_ = this.x_; this.original_y_ = this.y_; repaint (); } + return 0; + } + + public Image getImage () + { + return this.image_; } public void paint (Graphics g) |
