1

I am reading an grayscale tiff image into inputstream using

                InputStream is=objCMBObject.getDataStream();
                bytes = IOUtils.toByteArray(is);
                response.setContentType(mimeType);
                OutputStream os = response.getOutputStream();

and writing this stream into applet .but now I want to convert this grayscale image to binary image before writing to the applet. I don't want to save the image in file. How to convert inputstream of grayscale to binary?

I can convert the image into binary if I have x,y coordinates but I don't know how to get it from inputstream. Please guide.

happy
  • 2,550
  • 17
  • 64
  • 109

1 Answers1

0

When you want to manipulate an image, javax.imageio.ImageIO can be of great use. You can use that to load the image from the stream, apply some operation like a ColorConvertOp, and write the result back to a stream.

As ImageIO doesn't neccessarily support TIFF out of the box, you might have to use a suitable library to provide TIFF support. Answers to another question suggest using Java Advanced Imaging for this.

Community
  • 1
  • 1
MvG
  • 57,380
  • 22
  • 148
  • 276