Java Code Examples for javax.imageio.plugins.bmp.BMPImageWriteParam#canWriteCompressed()
The following examples show how to use
javax.imageio.plugins.bmp.BMPImageWriteParam#canWriteCompressed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BMPCompressionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static Iterator createTestSet(ImageWriter w) { List l = new LinkedList(); Test.iw = w; // variate compression types BMPImageWriteParam param = (BMPImageWriteParam)iw.getDefaultWriteParam(); param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionType("BI_RGB"); if (param.canWriteCompressed()) { String[] cTypes = param.getCompressionTypes(); String[] cDescr = param.getCompressionQualityDescriptions(); float[] cValues = param.getCompressionQualityValues(); if (cDescr == null) { System.out.println("There are no compression quality description!"); } else { for(int i=0; i<cDescr.length; i++) { System.out.println("Quality[" + i + "]=\""+cDescr[i]+"\""); } } if (cValues == null) { System.out.println("There are no compression quality values!"); } else { for(int i=0; i<cValues.length; i++) { System.out.println("Value["+i+"]=\""+cValues[i]+"\""); } } for(int i=0; i<cTypes.length; i++) { String compressionType = cTypes[i]; BufferedImage img = null; int type = BufferedImage.TYPE_INT_BGR; try { img = createTestImage(type); if (compressionType.equals("BI_RLE8")) { img = createTestImage2(8, DataBuffer.TYPE_BYTE); } else if (compressionType.equals("BI_RLE4")) { img = createTestImage3(4, DataBuffer.TYPE_BYTE); } else if (compressionType.equals("BI_BITFIELDS")) { img = createTestImage4(32); } } catch (IOException ex) { throw new RuntimeException("Unable to create test image"); } BMPImageWriteParam p = (BMPImageWriteParam)iw.getDefaultWriteParam(); System.out.println("Current compression type is \""+cTypes[i]+"\""); p.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); p.setCompressionType(compressionType); IIOMetadata md = iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), p); l.add( new Test(p, md, img)); } } // } return l.iterator(); }
Example 2
Source File: BMPCompressionTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static Iterator createTestSet(ImageWriter w) { List l = new LinkedList(); Test.iw = w; // variate compression types BMPImageWriteParam param = (BMPImageWriteParam)iw.getDefaultWriteParam(); param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionType("BI_RGB"); if (param.canWriteCompressed()) { String[] cTypes = param.getCompressionTypes(); String[] cDescr = param.getCompressionQualityDescriptions(); float[] cValues = param.getCompressionQualityValues(); if (cDescr == null) { System.out.println("There are no compression quality description!"); } else { for(int i=0; i<cDescr.length; i++) { System.out.println("Quality[" + i + "]=\""+cDescr[i]+"\""); } } if (cValues == null) { System.out.println("There are no compression quality values!"); } else { for(int i=0; i<cValues.length; i++) { System.out.println("Value["+i+"]=\""+cValues[i]+"\""); } } for(int i=0; i<cTypes.length; i++) { String compressionType = cTypes[i]; BufferedImage img = null; int type = BufferedImage.TYPE_INT_BGR; try { img = createTestImage(type); if (compressionType.equals("BI_RLE8")) { img = createTestImage2(8, DataBuffer.TYPE_BYTE); } else if (compressionType.equals("BI_RLE4")) { img = createTestImage3(4, DataBuffer.TYPE_BYTE); } else if (compressionType.equals("BI_BITFIELDS")) { img = createTestImage4(32); } } catch (IOException ex) { throw new RuntimeException("Unable to create test image"); } BMPImageWriteParam p = (BMPImageWriteParam)iw.getDefaultWriteParam(); System.out.println("Current compression type is \""+cTypes[i]+"\""); p.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); p.setCompressionType(compressionType); IIOMetadata md = iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), p); l.add( new Test(p, md, img)); } } // } return l.iterator(); }