aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/awt/image/ImageDecoder.java
diff options
context:
space:
mode:
authorThomas Fitzsimmons <fitzsim@redhat.com>2003-11-12 00:37:34 +0000
committerThomas Fitzsimmons <fitzsim@gcc.gnu.org>2003-11-12 00:37:34 +0000
commita5966c9ef9036294c09f0729f9950b90b1d1c3b5 (patch)
tree76d0f90da057662bc2f5deb1bc000be30244807e /libjava/gnu/java/awt/image/ImageDecoder.java
parentc754c6f1311f79ce60dfdf9e8d61b9557a36808f (diff)
downloadgcc-a5966c9ef9036294c09f0729f9950b90b1d1c3b5.zip
gcc-a5966c9ef9036294c09f0729f9950b90b1d1c3b5.tar.gz
gcc-a5966c9ef9036294c09f0729f9950b90b1d1c3b5.tar.bz2
Makefile.am: Add GdkPixbufDecoder.java and gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
2003-11-11 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am: Add GdkPixbufDecoder.java and gnu_java_awt_peer_gtk_GdkPixbufDecoder.c * Makefile.in: Regenerate. * gnu/java/awt/image/ImageDecoder.java (ImageDecoder(byte[],int,int)): New constructor. (startProduction): Create ByteArrayInputStream when url and filename are null. (produce): Declare stream parameter as InputStream. * gnu/java/awt/image/XBMDecoder.java (produce): Declare stream parameter as InputStream. * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java (GdkPixbufDecoder(byte[],int,int)): New constructor. (produce): Declare stream parameter as InputStream. * gnu/java/awt/peer/gtk/GtkComponentPeer.java (prepareImage): Throw NPE if image is null. Set image's observer before running PrepareImage thread. Pass image to startProduction. * gnu/java/awt/peer/gtk/GtkImage.java: Add null checks before calls to source's member functions. (observer): New field. (setObserver): New method. (setDimensions, setPixels, imageComplete): Call observer's imageUpdate. * gnu/java/awt/peer/gtk/GtkToolkit.java (checkImage, getImage): Return new GtkImage. (prepareImage): Implement. * java/awt/Component.java: Add static fields incrementalDraw and redrawRate. (imageUpdate): Implement. (createImage): Call Toolkit's createImage if peer is null. (prepareImage): Throw NPE if image is null. * java/awt/MediaTracker.java: Fix return value. From-SVN: r73476
Diffstat (limited to 'libjava/gnu/java/awt/image/ImageDecoder.java')
-rw-r--r--libjava/gnu/java/awt/image/ImageDecoder.java34
1 files changed, 28 insertions, 6 deletions
diff --git a/libjava/gnu/java/awt/image/ImageDecoder.java b/libjava/gnu/java/awt/image/ImageDecoder.java
index 4d3fbec..d44efce 100644
--- a/libjava/gnu/java/awt/image/ImageDecoder.java
+++ b/libjava/gnu/java/awt/image/ImageDecoder.java
@@ -48,6 +48,10 @@ public abstract class ImageDecoder implements ImageProducer
Vector consumers = new Vector ();
String filename;
URL url;
+ byte[] data;
+ int offset;
+ int length;
+ InputStream input;
public static ColorModel cm;
@@ -69,6 +73,13 @@ public abstract class ImageDecoder implements ImageProducer
this.url = url;
}
+ public ImageDecoder (byte[] imagedata, int imageoffset, int imagelength)
+ {
+ data = imagedata;
+ offset = imageoffset;
+ length = imagelength;
+ }
+
public void addConsumer (ImageConsumer ic)
{
consumers.addElement (ic);
@@ -90,11 +101,22 @@ public abstract class ImageDecoder implements ImageProducer
Vector list = (Vector) consumers.clone ();
try
{
- FileInputStream is = (url == null) ? new FileInputStream (filename) :
- (FileInputStream) url.openStream();
-
- produce (list, is);
- }
+ // Create the input stream here rather than in the
+ // ImageDecoder constructors so that exceptions cause
+ // imageComplete to be called with an appropriate error
+ // status.
+ if (url != null)
+ input = url.openStream();
+ else
+ {
+ if (filename != null)
+ input = new FileInputStream (filename);
+ else
+ input = new ByteArrayInputStream (data, offset, length);
+ }
+
+ produce (list, input);
+ }
catch (Exception e)
{
for (int i = 0; i < list.size (); i++)
@@ -109,5 +131,5 @@ public abstract class ImageDecoder implements ImageProducer
{
}
- abstract void produce (Vector v, FileInputStream is) throws IOException;
+ abstract void produce (Vector v, InputStream is) throws IOException;
}