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


Java ColorModel.getPixelSize方法代碼示例

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


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

示例1: printImageInfo

import java.awt.image.ColorModel; //導入方法依賴的package包/類
private void printImageInfo(BufferedImage image) {
    System.out.println("Image Type: " + image.getType());
    ColorModel colorModel = image.getColorModel();
    pixelSize = colorModel.getPixelSize();
    System.out.println("Pixel size: " + pixelSize);
    System.out.println("Alpha channel present: "
            + colorModel.hasAlpha());
}
 
開發者ID:varunon9,項目名稱:Image-Stegano,代碼行數:9,代碼來源:ImageStegano.java

示例2: getSurfaceType

import java.awt.image.ColorModel; //導入方法依賴的package包/類
public static SurfaceType getSurfaceType(ColorModel cm) {
    switch (cm.getPixelSize()) {
    case 32:
    case 24:
        if (cm instanceof DirectColorModel) {
            if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
                return IntRgbGdi;
            } else {
                return SurfaceType.IntRgbx;
            }
        } else {
            return ThreeByteBgrGdi;
        }
    case 15:
        return Ushort555RgbGdi;
    case 16:
        if ((cm instanceof DirectColorModel) &&
            (((DirectColorModel)cm).getBlueMask() == 0x3e))
        {
            return SurfaceType.Ushort555Rgbx;
        } else {
            return Ushort565RgbGdi;
        }
    case 8:
        if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
            cm instanceof ComponentColorModel) {
            return SurfaceType.ByteGray;
        } else if (cm instanceof IndexColorModel &&
                   isOpaqueGray((IndexColorModel)cm)) {
            return SurfaceType.Index8Gray;
        } else {
            return SurfaceType.ByteIndexedOpaque;
        }
    default:
        throw new sun.java2d.InvalidPipeException("Unsupported bit " +
                                                  "depth: " +
                                                  cm.getPixelSize());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:40,代碼來源:GDIWindowSurfaceData.java

示例3: GDIWindowSurfaceData

import java.awt.image.ColorModel; //導入方法依賴的package包/類
private GDIWindowSurfaceData(WComponentPeer peer, SurfaceType sType) {
    super(sType, peer.getDeviceColorModel());
    ColorModel cm = peer.getDeviceColorModel();
    this.peer = peer;
    int rMask = 0, gMask = 0, bMask = 0;
    int depth;
    switch (cm.getPixelSize()) {
    case 32:
    case 24:
        if (cm instanceof DirectColorModel) {
            depth = 32;
        } else {
            depth = 24;
        }
        break;
    default:
        depth = cm.getPixelSize();
    }
    if (cm instanceof DirectColorModel) {
        DirectColorModel dcm = (DirectColorModel)cm;
        rMask = dcm.getRedMask();
        gMask = dcm.getGreenMask();
        bMask = dcm.getBlueMask();
    }
    this.graphicsConfig =
        (Win32GraphicsConfig) peer.getGraphicsConfiguration();
    this.solidloops = graphicsConfig.getSolidLoops(sType);

    Win32GraphicsDevice gd =
        (Win32GraphicsDevice)graphicsConfig.getDevice();
    initOps(peer, depth, rMask, gMask, bMask, gd.getScreen());
    setBlitProxyKey(graphicsConfig.getProxyKey());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:34,代碼來源:GDIWindowSurfaceData.java

示例4: X11SurfaceData

import java.awt.image.ColorModel; //導入方法依賴的package包/類
protected X11SurfaceData(X11ComponentPeer peer,
                         X11GraphicsConfig gc,
                         SurfaceType sType,
                         ColorModel cm) {
    super(sType, cm);
    this.peer = peer;
    this.graphicsConfig = gc;
    this.solidloops = graphicsConfig.getSolidLoops(sType);
    this.depth = cm.getPixelSize();
    initOps(peer, graphicsConfig, depth);
    if (isAccelerationEnabled()) {
        setBlitProxyKey(gc.getProxyKey());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:X11SurfaceData.java

示例5: setColorModel

import java.awt.image.ColorModel; //導入方法依賴的package包/類
@Override
public synchronized void setColorModel(ColorModel model){
    int newPixelFormat = getPixelFormatForColorModel(model);
    if( model.getPixelSize() <= 8 ){
    	newPixelFormat = DEFAULT_PIXEL_FORMAT;
    }
    if( newPixelFormat != pixelFormat && bitmap != null ){
    	// force reconstruct of the bitmap due to a color model change
    	bitmap.Dispose();
    	bitmap = null;
    }
    pixelFormat = newPixelFormat;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:ImageRepresentation.java

示例6: 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

示例7: GDIWindowSurfaceData

import java.awt.image.ColorModel; //導入方法依賴的package包/類
private GDIWindowSurfaceData(WComponentPeer peer, SurfaceType sType) {
    super(sType, peer.getDeviceColorModel());
    ColorModel cm = peer.getDeviceColorModel();
    this.peer = peer;
    int rMask = 0, gMask = 0, bMask = 0;
    int depth;
    switch (cm.getPixelSize()) {
    case 32:
    case 24:
        if (cm instanceof DirectColorModel) {
            depth = 32;
        } else {
            depth = 24;
        }
        break;
    default:
        depth = cm.getPixelSize();
    }
    if (cm instanceof DirectColorModel) {
        DirectColorModel dcm = (DirectColorModel)cm;
        rMask = dcm.getRedMask();
        gMask = dcm.getGreenMask();
        bMask = dcm.getBlueMask();
    }
    this.graphicsConfig =
        (Win32GraphicsConfig) peer.getGraphicsConfiguration();
    this.solidloops = graphicsConfig.getSolidLoops(sType);
    Win32GraphicsDevice gd = graphicsConfig.getDevice();
    scaleX = gd.getDefaultScaleX();
    scaleY = gd.getDefaultScaleY();
    initOps(peer, depth, rMask, gMask, bMask, gd.getScreen());
    setBlitProxyKey(graphicsConfig.getProxyKey());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:GDIWindowSurfaceData.java

示例8: createProxy

import java.awt.image.ColorModel; //導入方法依賴的package包/類
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:42,代碼來源:X11SurfaceDataProxy.java

示例9: getDisplayMode

import java.awt.image.ColorModel; //導入方法依賴的package包/類
/**
 * Returns the current display mode of this
 * <code>GraphicsDevice</code>.
 * The returned display mode is allowed to have a refresh rate
 * {@link DisplayMode#REFRESH_RATE_UNKNOWN} if it is indeterminate.
 * Likewise, the returned display mode is allowed to have a bit depth
 * {@link DisplayMode#BIT_DEPTH_MULTI} if it is indeterminate or if multiple
 * bit depths are supported.
 * @return the current display mode of this graphics device.
 * @see #setDisplayMode(DisplayMode)
 * @since 1.4
 */
public DisplayMode getDisplayMode() {
    GraphicsConfiguration gc = getDefaultConfiguration();
    Rectangle r = gc.getBounds();
    ColorModel cm = gc.getColorModel();
    return new DisplayMode(r.width, r.height, cm.getPixelSize(), 0);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:GraphicsDevice.java

示例10: getDisplayMode

import java.awt.image.ColorModel; //導入方法依賴的package包/類
/**
 * Returns the current display mode of this
 * {@code GraphicsDevice}.
 * The returned display mode is allowed to have a refresh rate
 * {@link DisplayMode#REFRESH_RATE_UNKNOWN} if it is indeterminate.
 * Likewise, the returned display mode is allowed to have a bit depth
 * {@link DisplayMode#BIT_DEPTH_MULTI} if it is indeterminate or if multiple
 * bit depths are supported.
 * @return the current display mode of this graphics device.
 * @see #setDisplayMode(DisplayMode)
 * @since 1.4
 */
public DisplayMode getDisplayMode() {
    GraphicsConfiguration gc = getDefaultConfiguration();
    Rectangle r = gc.getBounds();
    ColorModel cm = gc.getColorModel();
    return new DisplayMode(r.width, r.height, cm.getPixelSize(), 0);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:GraphicsDevice.java


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