Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Please.....help!!!

1 view
Skip to first unread message

R T Sreeram

unread,
Feb 25, 1997, 3:00:00 AM2/25/97
to

Hi,

I am trying a view a GIF formated image from a
remote URL: I used the attached code(1) to retrieve
the Gif file. Now when I try to view this I get the
following error:

----------------------------------------------------
sun.awt.image.ImageFormatException: not a GIF file.
at sun.awt.image.GifImageDecoder.error(GifImageDecoder.java:84)
at
sun.awt.image.GifImageDecoder.readHeader(GifImageDecoder.java:210)
at
sun.awt.image.GifImageDecoder.produceImage(GifImageDecoder.java:113)
at
sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:223)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:106)
-----------------------------------------------------

I tested the Gif file using another program [code (2)] posted in
the news group by "Daniel Leuck <d...@tollan.com>" Sun, 23 Feb 1997
21:46:12 -0800. This was to make sure that the Gif file
is of the right format and that worked fine.

Code(2):

---------------------------------------------------------------
import java.applet.*;
import java.awt.*;

public class ImageView extends java.applet.Applet {

Image myImage;

public void init()

{
myImage = getImage(getCodeBase(),"test.gif");
}

public void paint(Graphics g)

{
g.drawImage(myImage,0,0,this);
}

}
-----------------------------------------------------------------


Could anyone tell me why this is happening with my first code????

Code (1) : Please see below.


import java.applet.*;
import java.awt.*;
import java.net.*;
import java.awt.image.*;

public class AnApplet extends Applet implements Runnable {
Thread myThread;
Image myImage;
URL myURL;
String errTxt = "Initializing";
int x,y;
//
public void init() {
myURL = null;
myThread = null;
x = 0;
y = 0;
myImage = null;
}
public void start() {
if (myThread == null) {
myThread = new Thread(this);
myThread.start();
}
}
public void stop() {
if (myThread != null) {
myThread.stop();
myThread = null;
}
}
public void run() {
try {myURL = new
URL("http://www.bath.ac.uk/~enprts/test.gif");}
catch(MalformedURLException e) {
errTxt = new String("new URL Faliure");
this.showStatus(errTxt);
this.stop();
}
myImage = getImage(myURL);
if (myImage == null) {
errTxt = new String("getImage returned null");
this.showStatus(errTxt);
this.stop();
}

}
public void paint(Graphics g) {
g.drawImage(myImage,0,0,this);
}
public void sleep (int period) {
try {Thread.sleep(period);}
catch(InterruptedException e) {}
}
}

Hans Juergen von Lengerke

unread,
Feb 25, 1997, 3:00:00 AM2/25/97
to

On Tue, 25 Feb 1997 10:44:37 GMT R T Sreeram <enp...@bath.ac.uk> wrote:

-] Hi,

-] I am trying a view a GIF formated image from a
-] remote URL: I used the attached code(1) to retrieve
-] the Gif file. Now when I try to view this I get the
-] following error:

<snip>

Hi,

I compiled your code with JDK 1.1 and started the applet using the
appletviewer. Following error occured (which is different from your error):

========================================================================
Exception occurred during event handling:
java.lang.NullPointerException
at sun.awt.windows.WGraphics.drawImage(WGraphics.java:222)
at AnApplet.paint(AnApplet.java:49)
at java.awt.Component.dispatchEventImpl(Component.java:1380)
at java.awt.Container.dispatchEventImpl(Container.java:818)
at java.awt.Component.dispatchEvent(Component.java:1361)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:58)
========================================================================

But: the applet obtained the image and showed it in the
appletviewer window.

Don't know whether this helps you, but at least the applet
gets the image using JDK 1.1.

Good luck,
Hans

BTW, why do you crosspost this?


R T Sreeram

unread,
Feb 25, 1997, 3:00:00 AM2/25/97
to

>
> Hi,

>
> I am trying a view a GIF formated image from a
> remote URL: I used the attached code(1) to retrieve
> the Gif file. Now when I try to view this I get the

SuperCede Internet Account

unread,
Feb 25, 1997, 3:00:00 AM2/25/97
to R T Sreeram

Make sure it is a standard GIF image. Java cannot read 16-bit GIF
images (a non-standard variation of GIF), but Netscape can.

-----
Jake Cormier
SuperCede Technical Support
Asymtrix Corporation
Check out "The Fastest Java on the Planet" at
http://www.asymetrix.com/products/supercede/revup.html

Jennifer Cook

unread,
Mar 29, 1997, 3:00:00 AM3/29/97
to

R T Sreeram <enp...@bath.ac.uk> wrote:

Good news, I think. I tested your applet #1 - and it worked!
If both of your tests used the same gif, there is only answers I can
think of are: it's your JDK, or your platform. Mine are
WIN32/Windows95 and JDK 1.1.1.

Best of luck.

Jim Cook


0 new messages