jai

Read byte array into buffered image WITHOUT ImageIO

送分小仙女□ 提交于 2020-01-15 12:16:08
问题 I have a code that turns a byte array into BufferedImage using ImageIO. public void readImage(byte[] imageBytes) { ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes); BufferedImage bufferedImage = null; try { bufferedImage = ImageIO.read(inputStream); } catch (Exception e) { e.printStackTrace(); } // do something with bufferedImage } But I found that for certain jpeg images, it throws a CMMException, every time. Here's the stack trace: java.awt.color.CMMException: Cannot

Read byte array into buffered image WITHOUT ImageIO

删除回忆录丶 提交于 2020-01-15 12:16:07
问题 I have a code that turns a byte array into BufferedImage using ImageIO. public void readImage(byte[] imageBytes) { ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes); BufferedImage bufferedImage = null; try { bufferedImage = ImageIO.read(inputStream); } catch (Exception e) { e.printStackTrace(); } // do something with bufferedImage } But I found that for certain jpeg images, it throws a CMMException, every time. Here's the stack trace: java.awt.color.CMMException: Cannot

Write a .TIFF with JAI

一笑奈何 提交于 2020-01-15 09:01:05
问题 I'm a beginner in Java and a geomatics student. I'am using IntelliJ. I would like to create a TIFF from a BufferedImage. This is my code : byte[] buffer = new byte[width * height]; ColorSpace cs = ColorSpace.getInstance( ColorSpace.CS_GRAY ); int[] nBits = { 8 }; ColorModel cm = new ComponentColorModel( cs, nBits, false, true,Transparency.OPAQUE, DataBuffer.TYPE_BYTE ); SampleModel sm = cm.createCompatibleSampleModel( width, height ); DataBufferByte db = new DataBufferByte( buffer, width *

How to combine two or many tiff image files in to one multipage tiff image in JAVA

百般思念 提交于 2020-01-10 02:00:22
问题 I have 5 single page tiff images. I want to combine all these 5 tiff images in to one multipage tiff image. I am using Java Advanced Imaging API. I have read the JAI API documentation and tutorials given by SUN. I am new to JAI. I know the basic core java. I dont understand those documentation and turorial by SUN. So friends Please tell me how to combine 5 tiff image file in to one multipage tiff image. Please give me some guidence on above topic. I have been searching internet for above

How to convert 16 bit Gray Scale image to RGB image in java?

笑着哭i 提交于 2020-01-06 04:20:11
问题 I'm making a desktop app in Java Swing using the Netbeans platform. I want to convert a 16 bit gray scale image to an RGB image. How can I do that? 回答1: Grayscale is held in a single value, black, whereas RBG is held in three, red, blue, and green. The best you can do with this is a monochromatic image, which you can do with the getRGB(x, y) method in the BufferedImage class. Since your input image is in grayscale, you can take any of the three color values from that because they should be

JPEG in TIFF encoding

蹲街弑〆低调 提交于 2020-01-04 10:45:50
问题 I do this steps: TIFFEncodeParam tep = new TIFFEncodeParam(); tep.setCompression(TIFFEncodeParam.COMPRESSION_JPEG_TTN2); BufferedImage buff = new BufferedImage(newimage.getWidth(null), newimage.getHeight(null), BufferedImage.TYPE_BYTE_BINARY); //newimage is an awt image buff.createGraphics().drawImage(newimage, 0,0,null); ParameterBlock outPB = new ParameterBlock(); outPB.addSource(buff); outPB.add("myjpegfile.jpg"); outPB.add("tiff"); outPB.add(tep); PlanarImage outPI = JAI.create("filestore

JPEG in TIFF encoding

我只是一个虾纸丫 提交于 2020-01-04 10:43:12
问题 I do this steps: TIFFEncodeParam tep = new TIFFEncodeParam(); tep.setCompression(TIFFEncodeParam.COMPRESSION_JPEG_TTN2); BufferedImage buff = new BufferedImage(newimage.getWidth(null), newimage.getHeight(null), BufferedImage.TYPE_BYTE_BINARY); //newimage is an awt image buff.createGraphics().drawImage(newimage, 0,0,null); ParameterBlock outPB = new ParameterBlock(); outPB.addSource(buff); outPB.add("myjpegfile.jpg"); outPB.add("tiff"); outPB.add(tep); PlanarImage outPI = JAI.create("filestore

JPEG in TIFF encoding

大城市里の小女人 提交于 2020-01-04 10:43:10
问题 I do this steps: TIFFEncodeParam tep = new TIFFEncodeParam(); tep.setCompression(TIFFEncodeParam.COMPRESSION_JPEG_TTN2); BufferedImage buff = new BufferedImage(newimage.getWidth(null), newimage.getHeight(null), BufferedImage.TYPE_BYTE_BINARY); //newimage is an awt image buff.createGraphics().drawImage(newimage, 0,0,null); ParameterBlock outPB = new ParameterBlock(); outPB.addSource(buff); outPB.add("myjpegfile.jpg"); outPB.add("tiff"); outPB.add(tep); PlanarImage outPI = JAI.create("filestore

JPEG in TIFF encoding

馋奶兔 提交于 2020-01-04 10:42:54
问题 I do this steps: TIFFEncodeParam tep = new TIFFEncodeParam(); tep.setCompression(TIFFEncodeParam.COMPRESSION_JPEG_TTN2); BufferedImage buff = new BufferedImage(newimage.getWidth(null), newimage.getHeight(null), BufferedImage.TYPE_BYTE_BINARY); //newimage is an awt image buff.createGraphics().drawImage(newimage, 0,0,null); ParameterBlock outPB = new ParameterBlock(); outPB.addSource(buff); outPB.add("myjpegfile.jpg"); outPB.add("tiff"); outPB.add(tep); PlanarImage outPI = JAI.create("filestore

Determine DPI of Image in Java

∥☆過路亽.° 提交于 2020-01-02 08:21:30
问题 I have a TIFF image that has been read in to my application and is stored in a BufferedImage object. How can I determine the horizontal and vertical DPI of the image using the Java Advanced Imaging (JAI) APIs? I have been looking around and not been able to find a straight forward way to accomplish this. 回答1: Here's a full example extracting DPI (well, pixels per mm, really) using the standard ImageIO API and the standard metadata format. Complexity, here we come... :-P public class DPITest {