当前位置: 首页>>代码示例>>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;未经允许,请勿转载。