java getcolormodel_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

​點讚 2

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,

示例2: getSurfaceType

​點讚 2

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,

示例3: GDIWindowSurfaceData

​點讚 2

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,

示例4: X11SurfaceData

​點讚 2

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,

示例5: setColorModel

​點讚 2

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,

示例6: getPixelFormatForColorModel

​點讚 2

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,

示例7: GDIWindowSurfaceData

​點讚 2

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,

示例8: createProxy

​點讚 2

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,

示例9: getDisplayMode

​點讚 1

import java.awt.image.ColorModel; //導入方法依賴的package包/類

/**

* Returns the current display mode of this

* 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:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,

示例10: getDisplayMode

​點讚 1

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,

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值