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


Java ColorModel.getComponentSize方法代碼示例

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


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

示例1: canEncodeImage

import java.awt.image.ColorModel; //導入方法依賴的package包/類
public boolean canEncodeImage(ImageTypeSpecifier type) {
    if (type == null) {
        throw new IllegalArgumentException("type == null!");
    }

    SampleModel sm = type.getSampleModel();
    ColorModel cm = type.getColorModel();

    boolean canEncode = sm.getNumBands() == 1 &&
        sm.getSampleSize(0) <= 8 &&
        sm.getWidth() <= 65535 &&
        sm.getHeight() <= 65535 &&
        (cm == null || cm.getComponentSize()[0] <= 8);

    if (canEncode) {
        return true;
    } else {
        return PaletteBuilder.canCreatePalette(type);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:GIFImageWriterSpi.java

示例2: needToCreateIndex

import java.awt.image.ColorModel; //導入方法依賴的package包/類
private boolean needToCreateIndex(RenderedImage image) {

        SampleModel sampleModel = image.getSampleModel();
        ColorModel colorModel = image.getColorModel();

        return sampleModel.getNumBands() != 1 ||
            sampleModel.getSampleSize()[0] > 8 ||
            colorModel.getComponentSize()[0] > 8;
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:GIFImageWriter.java

示例3: getPixelFormatForColorModel

import java.awt.image.ColorModel; //導入方法依賴的package包/類
private int getPixelFormatForColorModel( ColorModel cm ){
	if( cm == null ){
		return DEFAULT_PIXEL_FORMAT; // TODO is PixelFormat.Canonical better here?
	}
	int bpp = cm.getPixelSize();
	int[] sizes = cm.getComponentSize();
	switch( bpp ){
		case 1: return PixelFormat.Undefined; // Indexed is invalid and there is no 1bpp
		case 4: return PixelFormat.Format4bppIndexed;
		case 8: return PixelFormat.Format8bppIndexed;
		case 16:
			if( sizes.length <= 1) {
				return PixelFormat.Format16bppGrayScale;
			}
			if( sizes.length == 3 ){
				if( sizes[0] == 5 && sizes[2] == 5 ){
					return sizes[1] == 5 ? PixelFormat.Format16bppRgb555 : PixelFormat.Format16bppRgb565;
				}
			}
			if( sizes.length == 4 && cm.hasAlpha() ){
				return PixelFormat.Format16bppArgb1555;
			}
			break;
		case 24:
			return PixelFormat.Format24bppRgb;
		case 32:
			if(!cm.hasAlpha()){
				return PixelFormat.Format32bppRgb;
			} else {
				return cm.isAlphaPremultiplied() ? PixelFormat.Format32bppPArgb : PixelFormat.Format32bppArgb;
			}
		case 48:
			return PixelFormat.Format48bppRgb;
		case 64:
			return cm.isAlphaPremultiplied() ? PixelFormat.Format64bppPArgb : PixelFormat.Format64bppArgb;    			
	}
	return PixelFormat.Undefined;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:ImageRepresentation.java


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