本文整理汇总了Java中org.freehep.graphicsio.ImageConstants.JPG属性的典型用法代码示例。如果您正苦于以下问题:Java ImageConstants.JPG属性的具体用法?Java ImageConstants.JPG怎么用?Java ImageConstants.JPG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.freehep.graphicsio.ImageConstants
的用法示例。
在下文中一共展示了ImageConstants.JPG属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ImageBytes
/**
* Encodes the passed image
*
* @param image image to convert
* @param bkg background color
* @param format format could be {@link ImageConstants#ZLIB} or {@link ImageConstants#JPEG}
* @param colorModel e.g. {@link org.freehep.graphicsio.ImageConstants#COLOR_MODEL_RGB}
* @throws IOException thrown by {@link org.freehep.graphicsio.ImageGraphics2D#toByteArray(java.awt.image.RenderedImage, String, String, java.util.Properties)}
*/
public ImageBytes(RenderedImage image, Color bkg, String format, String colorModel) throws IOException {
// ZLIB encoding, transparent images allways require ZLIB
if (ImageConstants.ZLIB.equals(format) || (image.getColorModel().hasAlpha() && (bkg == null))) {
bytes = toZLIB(image, bkg, colorModel);
this.format = ImageConstants.ZLIB;
}
// JPG encoding
else if (ImageConstants.JPEG.equals(format)) {
bytes = toJPG(image);
this.format = ImageConstants.JPG;
} else {
// calculate both byte arrays
byte[] jpgBytes = toJPG(image);
byte[] zlibBytes = toZLIB(image, bkg, colorModel);
// compare sizes to determine smalles format
if (jpgBytes.length < 0.5 * zlibBytes.length) {
bytes = jpgBytes;
this.format = ImageConstants.JPG;
} else {
bytes = zlibBytes;
this.format = ImageConstants.ZLIB;
}
}
}
示例2: inlineImage
/**
* Inline Image convenience function (see Table 4.39 and 4.40). Ouputs the
* data of the image using "DeviceRGB" colorspace, and the requested
* encoding.
* @param image Image to write
* @param bkg Background color, null for transparent image
* @param encode {@link org.freehep.graphicsio.ImageConstants#ZLIB} or {@link org.freehep.graphicsio.ImageConstants#JPG}
* @throws java.io.IOException thrown by ImageBytes
*/
public void inlineImage(RenderedImage image, Color bkg, String encode)
throws IOException {
ImageBytes bytes = new ImageBytes(image, bkg, ImageConstants.JPG, ImageConstants.COLOR_MODEL_RGB);
println("BI");
imageInfo("Width", image.getWidth());
imageInfo("Height", image.getHeight());
imageInfo("ColorSpace", pdf.name("DeviceRGB"));
imageInfo("BitsPerComponent", 8);
imageInfo("Filter", getFilterName(bytes.getFormat()));
print("ID\n");
write(bytes.getBytes());
println("\nEI");
}