Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > BUG in Java ImageIO,problem in JPEGImageDecoder,can't read or write image

Reply
Thread Tools

BUG in Java ImageIO,problem in JPEGImageDecoder,can't read or write image

 
 
Subha
Guest
Posts: n/a
 
      10-23-2006
HI,
I got an excepton while trying to save an dynamically
generated image file in the local memory using the ImageIO class.Here
is the code snippent I wrote:


/* Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRect);
// save captured image to jpg file
ImageIO.write(image, "jpg", new File(outFileName));*/

And here is the exception I am finding (I never found this before, I
runned the code thousands times before)

/*java.io.FileNotFoundException: pic5.jpg (Access is denied)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.j ava:212)
at
javax.imageio.stream.FileImageOutputStream.<init>( FileImageOutputStream.java:44)
at
com.sun.imageio.spi.FileImageOutputStreamSpi.creat eOutputStreamInstance(FileImageOutputStreamSpi.jav a:37)
at
javax.imageio.ImageIO.createImageOutputStream(Imag eIO.java:391)
at javax.imageio.ImageIO.write(ImageIO.java:1483)
at Test_ScreenShot.main(Test_ScreenShot.java:112)
at Test_Main.main(Test_Main.java:466)
at Test_ScreenShot.main(Test_ScreenShot.java:129)
Press any key to continue...*/

When I googled I found the following informations:-
1)from sun's bug database:-
http://bugs.sun.com/bugdatabase/view...bug_id=6247985

2)from SUN Developer Forums

http://forum.java.sun.com/thread.jsp...sageID=4382833

3)from Java.NET forum(here they r getting the bug while they r using
createScreenCapture() method of robot class,I am also using that in my
code)
http://forums.java.net/jive/thread.j...ssageID=123247

4)from SUN's archieve
http://archives.java.sun.com/cgi-bin...est&D=0&P=1483

5)Here is the actual implemetation of ImageIO class.I'm getting error
at 391 no. line.
http://kickjava.com/src/javax/imageio/ImageIO.java.htm

================================================== ==========================================
Now I tried the following alterntive form jdk 1.2
to read:-
FileInputStream fis = new FileInputStream(file);
JPEGImageDecoder jpeg = JPEGCodec.createJPEGDecoder(fis);
jpeg.decodeAsBufferedImage();
fis.close();

But after running a long time suddenly its giving exception:-
Exception in thread "main"
com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts
with 0xff 0xd9
at
sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGS tream(Native Method)
at
sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsB ufferedImage(Unknown
Source)
================================================== ==========================================

My question is:-
What is the way to read and write image in JDK?Is there any bug free
way?what is it?



Thanks And Regards
Subhadip

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      10-23-2006
Subha wrote:
> HI,


Please refrain from multi-posting in future.

(X-post to c.l.j.h./c.l.j.p./s.i.p., w/ f-u to c.l.j.h. only)

Andrew T.

 
Reply With Quote
 
 
 
 
EJP
Guest
Posts: n/a
 
      10-24-2006
Subha wrote:

> When I googled I found the following informations:-
> 1)from sun's bug database:-
> http://bugs.sun.com/bugdatabase/view...bug_id=6247985


This is irrelevant. It is about IllegalArgumentException.

> 2)from SUN Developer Forums
>
> http://forum.java.sun.com/thread.jsp...sageID=4382833


This gives the correct explanation. You don't have write access to that
file or directory. Maybe it is open?

> 3)from Java.NET forum(here they r getting the bug while they r using
> createScreenCapture() method of robot class,I am also using that in my
> code)
> http://forums.java.net/jive/thread.j...ssageID=123247


This repeats the same explanation.

> 4)from SUN's archieve
> http://archives.java.sun.com/cgi-bin...est&D=0&P=1483


This is irrelevant. It is about resolution.

> 5)Here is the actual implemetation of ImageIO class.I'm getting error
> at 391 no. line.
> http://kickjava.com/src/javax/imageio/ImageIO.java.htm


No, this is the GNU version, which I sincerely hope you aren't using,
and obviously line 391 of this source code has nothing to do with your
problem, which is completely defined by your original exception.

> ================================================== ==========================================
> Now I tried the following alterntive form jdk 1.2
> to read:-


This isn't an 'alternative', this is reading an image instead of writing
it: aompletely different issue and a completely different problem. In
this case you are being told that the input file is corrupt.

What a lot of confusion over nothing.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to write Simple JAVA program to read and write from USB serialto use it with Arduino sahm Java 4 10-15-2012 06:24 PM
sys.stdout.write()'s bug or doc bug? Qiangning Hong Python 4 01-14-2009 11:20 AM
FF bug? Or IE bug? Text doesn't wrap around image in list elementwhen image is aligned. iwasjoeking HTML 9 06-09-2008 11:43 PM
Bug/Weak Implementation? popen* routines can't handle simultaneous read/write? dmoore Python 8 06-10-2007 05:36 AM
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM



Advertisments