List of usage examples for org.apache.commons.imaging.formats.tiff.constants TiffConstants TIFF_COMPRESSION_UNCOMPRESSED
int TIFF_COMPRESSION_UNCOMPRESSED
To view the source code for org.apache.commons.imaging.formats.tiff.constants TiffConstants TIFF_COMPRESSION_UNCOMPRESSED.
Click Source Link
From source file:editeurpanovisu.ReadWriteImage.java
public static void writeTiff(Image imgImage, String strNomFich, boolean bSharpen, float sharpenLevel) throws ImageReadException, IOException { File file = new File(strNomFich); BufferedImage imageRGBSharpen = null; BufferedImage imageRGB = SwingFXUtils.fromFXImage(imgImage, null); Graphics2D graphics = imageRGB.createGraphics(); graphics.drawImage(imageRGB, 0, 0, null); if (bSharpen) { imageRGBSharpen = new BufferedImage(imageRGB.getWidth(), imageRGB.getHeight(), BufferedImage.TYPE_INT_RGB); Kernel kernel = new Kernel(3, 3, sharpenMatrix); ConvolveOp cop = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); cop.filter(imageRGB, imageRGBSharpen); }/*from w w w . j a va 2s . c om*/ final ImageFormat format = ImageFormats.TIFF; final Map<String, Object> params = new HashMap<>(); params.put(ImagingConstants.PARAM_KEY_COMPRESSION, new Integer(TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED)); if (bSharpen) { try { Imaging.writeImage(imageRGBSharpen, file, format, params); } catch (ImageWriteException ex) { Logger.getLogger(ReadWriteImage.class.getName()).log(Level.SEVERE, null, ex); } } else { try { Imaging.writeImage(imageRGB, file, format, params); } catch (ImageWriteException ex) { Logger.getLogger(ReadWriteImage.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:org.apache.commons.imaging.examples.ImageWriteExample.java
public static byte[] imageWriteExample(final File file) throws ImageReadException, ImageWriteException, IOException { // read image final BufferedImage image = Imaging.getBufferedImage(file); final ImageFormat format = ImageFormats.TIFF; final Map<String, Object> params = new HashMap<>(); // set optional parameters if you like params.put(ImagingConstants.PARAM_KEY_COMPRESSION, Integer.valueOf(TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED)); final byte[] bytes = Imaging.writeImageToBytes(image, format, params); return bytes; }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
public void writeImage(File file) { if (offScreenCanvas == null) { fireFrameRendered();// ww w . ja v a2 s. c o m return; } offScreenRenderDone = false; try { offScreenCanvas.renderOffScreenBuffer(); } catch (NullPointerException c) { logger.error("Null pointer in offC.renderOffScreenBuffer()"); fireFrameRendered(); return; } if (!storingFrames) offScreenCanvas.waitForOffScreenRendering(); while (!offScreenRenderDone) try { wait(10); } catch (InterruptedException c) { } String ext = FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase(); if (ext == null) return; try { BufferedImage img = new BufferedImage(im.getWidth(), im.getHeight(), BufferedImage.TYPE_INT_RGB); img.createGraphics().drawImage(im, null, null); if (ext.equals("jpg") || ext.equals("jpeg")) ImageUtilities.writeJpeg(img, 1.0f, file); else if (ext.equals("png")) ImageUtilities.writePng(img, file); else if (ext.equals("gif")) ImageUtilities.writeGif(img, file); else if (ext.equals("tif") || ext.equals("tiff")) ImageUtilities.writeTiff(img, TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED, file); else if (ext.equals("bmp")) ImageUtilities.writeBmp(img, file); else if (ext.equals("pcx")) ImageUtilities.writePcx(img, file); else throw new IllegalArgumentException("Invalid file extension " + ext); } catch (IOException e) { logger.error("I/O exception for " + file.getAbsolutePath()); } fireFrameRendered(); }
From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java
public void writeImage(File file) { BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); dontWrite = true;/* w w w .ja va2s .c om*/ paintComponent(img.getGraphics()); dontWrite = false; String ext = FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase(); try { if (ext.equals("jpg") || ext.equals("jpeg")) { ImageUtilities.writeJpeg(img, 1.0f, file); } else if (ext.equals("png")) { ImageUtilities.writePng(img, file); } else if (ext.equals("gif")) { ImageUtilities.writeGif(img, file); } else if (ext.equals("tif") || ext.equals("tiff")) { ImageUtilities.writeTiff(img, TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED, file); } else if (ext.equals("bmp")) { ImageUtilities.writeBmp(img, file); } else if (ext.equals("pcx")) { ImageUtilities.writePcx(img, file); } else { throw new IllegalArgumentException("Invalid file extension " + ext); } } catch (IOException e) { System.out.println("I/O exception for " + file.getAbsolutePath()); } }
From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java
public static void writeTiff(BufferedImage img, int compression, File file) throws IOException { if (img == null) { return;//from w ww . java2 s. c om } final ImageFormat format = ImageFormats.TIFF; final Map<String, Object> params = new HashMap<String, Object>(); switch (compression) { case TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED: case TiffConstants.TIFF_COMPRESSION_CCITT_1D: case TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_3: case TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_4: case TiffConstants.TIFF_COMPRESSION_LZW: case TiffConstants.TIFF_COMPRESSION_PACKBITS: //case TiffConstants.TIFF_COMPRESSION_JPEG: break; default: compression = TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED; } ; params.put(ImagingConstants.PARAM_KEY_COMPRESSION, new Integer(compression)); try { Imaging.writeImage(img, file, format, params); } catch (ImageWriteException ex) { throw new IOException(ex); } }