Login  Register

Re: creating an ImagePlus from an InputStream or a byte[] -> SOLVED

Posted by Johannes Hermen on Dec 13, 2007; 7:06am
URL: http://imagej.273.s1.nabble.com/creating-an-ImagePlus-from-an-InputStream-or-a-byte-tp3697788p3697794.html

ImageJ Interest Group <[hidden email]> wrote on 12.12.2007 20:05:53:

> 1) Using ImageIO is probably your easiest bet, assuming the formats
> you need to support are limited to the common
> (non-discipline-specific) single-plane image formats: JPEG, PNG, GIF,
> BMP and TIFF.
>
> BufferedImage img = ImageIO.read(new ByteArrayInputStream(myBytes));
> ImagePlus imp = new ImagePlus(title, img);

This works for me so far.
Thanks a lot, I don't know why i didn't get this simple solution on my
own.....

I will keep in mind the other solutions for future problems ;-)

Anyway it would be nice to have a ImagePlus (or Opener) Constructor with
an InputStream, which shouldn't be that big problem. I think most of the
decoders and plugins used by the Opener Class work on an InputStream
anyway.

P.S. I allready Use the DICOM class and sun's TIFFDecoder to read Dicom
and Tiff images from a byte[], but it would be nice to have a general
solution.

-----------------------------------------------------------------
Johannes Hermen  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  http://www.santec.tudor.lu
29, Avenue John F. Kennedy
L-1855 Luxembourg
-----------------------------------------------------------------