當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageConstants.JPG屬性代碼示例

本文整理匯總了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;
        }
    }
}
 
開發者ID:phuseman,項目名稱:r2cat,代碼行數:36,代碼來源:ImageBytes.java

示例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");
}
 
開發者ID:phuseman,項目名稱:r2cat,代碼行數:28,代碼來源:PDFStream.java


注:本文中的org.freehep.graphicsio.ImageConstants.JPG屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。