By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,779 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,779 IT Pros & Developers. It's quick & easy.

Problem with imageio: ImageReader stalls on JPEGs at ~95%

P: n/a
I'm trying to write some classes for my collaborative whiteboard to
transmit images over the network, using the javax.imageio API, but I'm
running into an odd problem: my code words fine with PNGs, but not
with JPEGs. As you can see below, I've attached a progress listener to
the reader, which reports progress up to just under 95%, then nothing.
The warning listener reports no warnings. The images are written by an
ImageWriter in another section of the code, which also uses the same
listeners, and *does* report completion w/o warnings. With PNGs, the
read completes just fine. Any help would be much appreciated; snippets
follow. (ImageStatusUpdater is a class of mine which implements
IIOReadProgressListener, IIOWriteProgressListener,
IIOReadWarningListener, and IIOWriteWarningListener.)

From the writer's code:

Socket _soc = serverSocket.accept();
ImageWriter _writer = (ImageWriter)
ImageIO.getImageWritersByFormatName(
format).next();
ImageStatusUpdater _isu = new ImageStatusUpdater();
_writer.addIIOWriteProgressListener(_isu);
_writer.addIIOWriteWarningListener(_isu);
_writer.setOutput(ImageIO.createImageOutputStream( _soc
.getOutputStream()));
_writer.write(image);

And the reader's:

Socket _socket = new Socket(ip, port);
ImageReader _ir = (ImageReader) ImageIO.
getImageReadersBySuffix(suffix).next();
ImageStatusUpdater _isu = new ImageStatusUpdater();
_ir.addIIOReadProgressListener(_isu);
_ir.addIIOReadWarningListener(_isu);
InputStream _is = _socket.getInputStream();
ImageInputStream _iis = ImageIO.createImageInputStream(_is);
_ir.setInput(_iis, true, true);
imageIcon.setImage(_ir.read(0));
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ak
> I'm trying to write some classes for my collaborative whiteboard to
transmit images over the network, using the javax.imageio API, but I'm
running into an odd problem: my code words fine with PNGs, but not
with JPEGs. As you can see below, I've attached a progress listener to
the reader, which reports progress up to just under 95%, then nothing.
The warning listener reports no warnings. The images are written by an
ImageWriter in another section of the code, which also uses the same
listeners, and *does* report completion w/o warnings. With PNGs, the
read completes just fine. Any help would be much appreciated; snippets
follow. (ImageStatusUpdater is a class of mine which implements
IIOReadProgressListener, IIOWriteProgressListener,
IIOReadWarningListener, and IIOWriteWarningListener.)

From the writer's code:

Socket _soc = serverSocket.accept();
ImageWriter _writer = (ImageWriter)
ImageIO.getImageWritersByFormatName(
format).next();
ImageStatusUpdater _isu = new ImageStatusUpdater();
_writer.addIIOWriteProgressListener(_isu);
_writer.addIIOWriteWarningListener(_isu);
_writer.setOutput(ImageIO.createImageOutputStream( _soc
.getOutputStream()));
_writer.write(image);


I think, that you need to flush your output stream just after writeImage.

--
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
Jul 17 '05 #2

P: n/a
"ak" <sp**@imagero.com> wrote in message news:<cb**********@online.de>...
I'm trying to write some classes for my collaborative whiteboard to
transmit images over the network, using the javax.imageio API, but I'm
running into an odd problem: my code words fine with PNGs, but not
with JPEGs. As you can see below, I've attached a progress listener to
the reader, which reports progress up to just under 95%, then nothing.
The warning listener reports no warnings. The images are written by an
ImageWriter in another section of the code, which also uses the same
listeners, and *does* report completion w/o warnings. With PNGs, the
read completes just fine. Any help would be much appreciated; snippets
follow. (ImageStatusUpdater is a class of mine which implements
IIOReadProgressListener, IIOWriteProgressListener,
IIOReadWarningListener, and IIOWriteWarningListener.)

From the writer's code:

Socket _soc = serverSocket.accept();
ImageWriter _writer = (ImageWriter)
ImageIO.getImageWritersByFormatName(
format).next();
ImageStatusUpdater _isu = new ImageStatusUpdater();
_writer.addIIOWriteProgressListener(_isu);
_writer.addIIOWriteWarningListener(_isu);
_writer.setOutput(ImageIO.createImageOutputStream( _soc
.getOutputStream()));
_writer.write(image);


I think, that you need to flush your output stream just after writeImage.

I just tried it, it doesn't help. Also, why would that affect JPEGs but not PNGs?
Jul 17 '05 #3

P: n/a

"Aaron Davies" <aa**********@gmail.com> wrote in message
news:c4**************************@posting.google.c om...
I'm trying to write some classes for my collaborative whiteboard to
transmit images over the network, using the javax.imageio API, but I'm
running into an odd problem: my code words fine with PNGs, but not
with JPEGs. As you can see below, I've attached a progress listener to
the reader, which reports progress up to just under 95%, then nothing.


It could be that the progress is actually 100% complete, but the listener is
stalled on the proverbial event-dispatch-loop while something in the cleanup
code is infinite-looping. Just a hint to look "outside the box".
--
regards,
Dar7yl (the 7 is silent)
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.