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


Java ImageTypeSpecifier.getBufferedImageType方法代碼示例

本文整理匯總了Java中javax.imageio.ImageTypeSpecifier.getBufferedImageType方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageTypeSpecifier.getBufferedImageType方法的具體用法?Java ImageTypeSpecifier.getBufferedImageType怎麽用?Java ImageTypeSpecifier.getBufferedImageType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.imageio.ImageTypeSpecifier的用法示例。


在下文中一共展示了ImageTypeSpecifier.getBufferedImageType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: canEncodeImage

import javax.imageio.ImageTypeSpecifier; //導入方法依賴的package包/類
private boolean canEncodeImage(String compression,
                               ImageTypeSpecifier imgType, int rawType)
{
    int biType = imgType.getBufferedImageType();
    if ((!compression.equals("BI_BITFIELDS")) &&
        ((rawType == BufferedImage.TYPE_USHORT_565_RGB) ||
         (rawType == TYPE_USHORT_565_BGR)))
    {
        return false;
    }

    int bpp = imgType.getColorModel().getPixelSize();
    if (compression.equals("BI_RLE4") && bpp != 4) {
        // only 4bpp images can be encoded as BI_RLE4
        return false;
    }
    if (compression.equals("BI_RLE8") && bpp != 8) {
        // only 8bpp images can be encoded as BI_RLE8
        return false;
    }

    if (compression.equals("BI_PNG") &&
        ((rawType == TYPE_USHORT_555_GRB) ||
         (rawType == TYPE_USHORT_555_BGR)))
    {
        return false;
    }

    return true;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:31,代碼來源:BMPSubsamplingTest.java

示例2: getPreferredCompressionType

import javax.imageio.ImageTypeSpecifier; //導入方法依賴的package包/類
protected int getPreferredCompressionType(ImageTypeSpecifier imageType) {
    if (imageType.getBufferedImageType() == BufferedImage.TYPE_USHORT_565_RGB) {
        return  BI_BITFIELDS;
    }
    return BI_RGB;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:BMPImageWriter.java

示例3: canEncodeImage

import javax.imageio.ImageTypeSpecifier; //導入方法依賴的package包/類
protected boolean canEncodeImage(int compression, ImageTypeSpecifier imgType) {
    ImageWriterSpi spi = this.getOriginatingProvider();
    if (!spi.canEncodeImage(imgType)) {
        return false;
    }
    int biType = imgType.getBufferedImageType();
    int bpp = imgType.getColorModel().getPixelSize();
    if (compressionType == BI_RLE4 && bpp != 4) {
        // only 4bpp images can be encoded as BI_RLE4
        return false;
    }
    if (compressionType == BI_RLE8 && bpp != 8) {
        // only 8bpp images can be encoded as BI_RLE8
        return false;
    }
    if (bpp == 16) {
        /*
         * Technically we expect that we may be able to
         * encode only some of SinglePixelPackedSampleModel
         * images here.
         *
         * In addition we should take into account following:
         *
         * 1. BI_RGB case, according to the MSDN description:
         *
         *     The bitmap has a maximum of 2^16 colors. If the
         *     biCompression member of the BITMAPINFOHEADER is BI_RGB,
         *     the bmiColors member of BITMAPINFO is NULL. Each WORD
         *     in the bitmap array represents a single pixel. The
         *     relative intensities of red, green, and blue are
         *     represented with five bits for each color component.
         *
         * 2. BI_BITFIELDS case, according ot the MSDN description:
         *
         *     Windows 95/98/Me: When the biCompression member is
         *     BI_BITFIELDS, the system supports only the following
         *     16bpp color masks: A 5-5-5 16-bit image, where the blue
         *     mask is 0x001F, the green mask is 0x03E0, and the red mask
         *     is 0x7C00; and a 5-6-5 16-bit image, where the blue mask
         *     is 0x001F, the green mask is 0x07E0, and the red mask is
         *     0xF800.
         */
        boolean canUseRGB = false;
        boolean canUseBITFIELDS = false;

        SampleModel sm = imgType.getSampleModel();
        if (sm instanceof SinglePixelPackedSampleModel) {
            int[] sizes =
                ((SinglePixelPackedSampleModel)sm).getSampleSize();

            canUseRGB = true;
            canUseBITFIELDS = true;
            for (int i = 0; i < sizes.length; i++) {
                canUseRGB       &=  (sizes[i] == 5);
                canUseBITFIELDS &= ((sizes[i] == 5) ||
                                    (i == 1 && sizes[i] == 6));
            }
        }

        return (((compressionType == BI_RGB) && canUseRGB) ||
                ((compressionType == BI_BITFIELDS) && canUseBITFIELDS));
    }
    return true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:65,代碼來源:BMPImageWriter.java

示例4: canEncodeImage

import javax.imageio.ImageTypeSpecifier; //導入方法依賴的package包/類
@Override
public boolean canEncodeImage(ImageTypeSpecifier type) {
  // TODO: Implement alpha support
  return ((type.getNumBands() == 3 && type.getBufferedImageType() == TYPE_3BYTE_BGR) ||
          (type.getNumBands() == 1 && type.getBufferedImageType() == TYPE_BYTE_GRAY));
}
 
開發者ID:dbmdz,項目名稱:imageio-jnr,代碼行數:7,代碼來源:OpenJp2ImageWriterSpi.java


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