本文整理匯總了Java中java.awt.image.ColorModel.getTransparency方法的典型用法代碼示例。如果您正苦於以下問題:Java ColorModel.getTransparency方法的具體用法?Java ColorModel.getTransparency怎麽用?Java ColorModel.getTransparency使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.image.ColorModel
的用法示例。
在下文中一共展示了ColorModel.getTransparency方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ByteFilter
import java.awt.image.ColorModel; //導入方法依賴的package包/類
public ByteFilter(ByteInterleavedRaster srcRas, ColorModel cm,
AffineTransform xform, int maxw)
{
super((cm.getTransparency() == Transparency.OPAQUE
? xrgbmodel : argbmodel),
xform, srcRas.getWidth(), srcRas.getHeight(), maxw);
this.inPalette = new int[256];
((IndexColorModel) cm).getRGBs(this.inPalette);
this.srcRas = srcRas;
this.inData = srcRas.getDataStorage();
this.inSpan = srcRas.getScanlineStride();
this.inOff = srcRas.getDataOffset(0);
}
示例2: createData
import java.awt.image.ColorModel; //導入方法依賴的package包/類
/**
* Creates a SurfaceData object representing an off-screen buffer (either
* a plain surface or Texture).
*/
public static D3DSurfaceData createData(D3DGraphicsConfig gc,
int width, int height,
ColorModel cm,
Image image, int type)
{
if (type == RT_TEXTURE) {
boolean isOpaque = cm.getTransparency() == Transparency.OPAQUE;
int cap = isOpaque ? CAPS_RT_TEXTURE_OPAQUE : CAPS_RT_TEXTURE_ALPHA;
if (!gc.getD3DDevice().isCapPresent(cap)) {
type = RT_PLAIN;
}
}
D3DSurfaceData ret = null;
try {
ret = new D3DSurfaceData(null, gc, width, height,
image, cm, 0, SWAP_DISCARD, VSYNC_DEFAULT,
type);
} catch (InvalidPipeException ipe) {
// try again - we might have ran out of vram, and rt textures
// could take up more than a plain surface, so it might succeed
if (type == RT_TEXTURE) {
// If a RT_TEXTURE was requested do not attempt to create a
// plain surface. (note that RT_TEXTURE can only be requested
// from a VI so the cast is safe)
if (((SunVolatileImage)image).getForcedAccelSurfaceType() !=
RT_TEXTURE)
{
type = RT_PLAIN;
ret = new D3DSurfaceData(null, gc, width, height,
image, cm, 0, SWAP_DISCARD,
VSYNC_DEFAULT, type);
}
}
}
return ret;
}
示例3: hasTransparentPixels
import java.awt.image.ColorModel; //導入方法依賴的package包/類
/**
* Return true if the BufferedImage argument has non-opaque
* bits in it and therefore can not be directly rendered by
* GDI. Return false if the image is opaque. If this function
* can not tell for sure whether the image has transparent
* pixels then it assumes that it does.
*/
protected boolean hasTransparentPixels(BufferedImage bufferedImage) {
ColorModel colorModel = bufferedImage.getColorModel();
boolean hasTransparency = colorModel == null
? true
: colorModel.getTransparency() != ColorModel.OPAQUE;
/*
* For the default INT ARGB check the image to see if any pixels are
* really transparent. If there are no transparent pixels then the
* transparency of the color model can be ignored.
* We assume that IndexColorModel images have already been
* checked for transparency and will be OPAQUE unless they actually
* have transparent pixels present.
*/
if (hasTransparency && bufferedImage != null) {
if (bufferedImage.getType()==BufferedImage.TYPE_INT_ARGB ||
bufferedImage.getType()==BufferedImage.TYPE_INT_ARGB_PRE) {
DataBuffer db = bufferedImage.getRaster().getDataBuffer();
SampleModel sm = bufferedImage.getRaster().getSampleModel();
if (db instanceof DataBufferInt &&
sm instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel psm =
(SinglePixelPackedSampleModel)sm;
// Stealing the data array for reading only...
int[] int_data =
SunWritableRaster.stealData((DataBufferInt) db, 0);
int x = bufferedImage.getMinX();
int y = bufferedImage.getMinY();
int w = bufferedImage.getWidth();
int h = bufferedImage.getHeight();
int stride = psm.getScanlineStride();
boolean hastranspixel = false;
for (int j = y; j < y+h; j++) {
int yoff = j * stride;
for (int i = x; i < x+w; i++) {
if ((int_data[yoff+i] & 0xff000000)!=0xff000000 ) {
hastranspixel = true;
break;
}
}
if (hastranspixel) {
break;
}
}
if (hastranspixel == false) {
hasTransparency = false;
}
}
}
}
return hasTransparency;
}
示例4: isBitmaskTransparency
import java.awt.image.ColorModel; //導入方法依賴的package包/類
protected boolean isBitmaskTransparency(BufferedImage bufferedImage) {
ColorModel colorModel = bufferedImage.getColorModel();
return (colorModel != null &&
colorModel.getTransparency() == ColorModel.BITMASK);
}
示例5: setColorModel
import java.awt.image.ColorModel; //導入方法依賴的package包/類
public void setColorModel(ColorModel model) {
if (src != null) {
src.checkSecurity(null, false);
}
srcModel = model;
// Check to see if model is INT_RGB
if (model instanceof IndexColorModel) {
if (model.getTransparency() == model.TRANSLUCENT) {
// REMIND:
// Probably need to composite anyway so force ARGB
cmodel = ColorModel.getRGBdefault();
srcLUT = null;
}
else {
IndexColorModel icm = (IndexColorModel) model;
numSrcLUT = icm.getMapSize();
srcLUT = new int[Math.max(numSrcLUT, 256)];
icm.getRGBs(srcLUT);
srcLUTtransIndex = icm.getTransparentPixel();
cmodel = model;
}
}
else {
if (cmodel == null) {
cmodel = model;
srcLUT = null;
}
else if (model instanceof DirectColorModel) {
// If it is INT_RGB or INT_ARGB, use the model
DirectColorModel dcm = (DirectColorModel) model;
if ((dcm.getRedMask() == 0xff0000) &&
(dcm.getGreenMask() == 0xff00) &&
(dcm.getBlueMask() == 0x00ff)) {
cmodel = model;
srcLUT = null;
}
}
}
isSameCM = (cmodel == model);
}
示例6: 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;
}
示例7: setColorModel
import java.awt.image.ColorModel; //導入方法依賴的package包/類
public void setColorModel(ColorModel model) {
if (src != null) {
src.checkSecurity(null, false);
}
srcModel = model;
// Check to see if model is INT_RGB
if (model instanceof IndexColorModel) {
if (model.getTransparency() == Transparency.TRANSLUCENT) {
// REMIND:
// Probably need to composite anyway so force ARGB
cmodel = ColorModel.getRGBdefault();
srcLUT = null;
}
else {
IndexColorModel icm = (IndexColorModel) model;
numSrcLUT = icm.getMapSize();
srcLUT = new int[Math.max(numSrcLUT, 256)];
icm.getRGBs(srcLUT);
srcLUTtransIndex = icm.getTransparentPixel();
cmodel = model;
}
}
else {
if (cmodel == null) {
cmodel = model;
srcLUT = null;
}
else if (model instanceof DirectColorModel) {
// If it is INT_RGB or INT_ARGB, use the model
DirectColorModel dcm = (DirectColorModel) model;
if ((dcm.getRedMask() == 0xff0000) &&
(dcm.getGreenMask() == 0xff00) &&
(dcm.getBlueMask() == 0x00ff)) {
cmodel = model;
srcLUT = null;
}
}
}
isSameCM = (cmodel == model);
}