本文整理汇总了Java中java.awt.image.DirectColorModel.getRedMask方法的典型用法代码示例。如果您正苦于以下问题:Java DirectColorModel.getRedMask方法的具体用法?Java DirectColorModel.getRedMask怎么用?Java DirectColorModel.getRedMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.DirectColorModel
的用法示例。
在下文中一共展示了DirectColorModel.getRedMask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractDirectRGBInt
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
private static byte[] extractDirectRGBInt( int aWidth, int aHeight, DirectColorModel aColorModel, SinglePixelPackedSampleModel aSampleModel, DataBufferInt aDataBuffer ) {
byte[] out = new byte[ aWidth * aHeight * 3 ];
int rMask = aColorModel.getRedMask();
int gMask = aColorModel.getGreenMask();
int bMask = aColorModel.getBlueMask();
int rShift = getShift( rMask );
int gShift = getShift( gMask );
int bShift = getShift( bMask );
int[] bank = aDataBuffer.getBankData()[ 0 ];
int scanlineStride = aSampleModel.getScanlineStride();
int scanIx = 0;
for ( int b = 0, y = 0; y < aHeight; y++ ) {
int pixIx = scanIx;
for ( int x = 0; x < aWidth; x++, b += 3 ) {
int pixel = bank[ pixIx++ ];
out[ b ] = ( byte ) ( ( pixel & rMask ) >>> rShift );
out[ b + 1 ] = ( byte ) ( ( pixel & gMask ) >>> gShift );
out[ b + 2 ] = ( byte ) ( ( pixel & bMask ) >>> bShift );
}
scanIx += scanlineStride;
}
return out;
}
示例2: equals
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
/** This checks to see if two DirectColorModels are identical.
* Apparently the "equals" method in DirectColorModel doesn't really work.
*/
private static boolean equals(DirectColorModel d1,DirectColorModel d2) {
if(d1.getAlphaMask()!=d2.getAlphaMask())
return false;
if(d1.getGreenMask()!=d2.getGreenMask())
return false;
if(d1.getRedMask()!=d2.getRedMask())
return false;
if(d1.getBlueMask()!=d2.getBlueMask())
return false;
if(d1.getColorSpace()!=d2.getColorSpace())
return false;
if(d1.isAlphaPremultiplied()!=d2.isAlphaPremultiplied())
return false;
if(d1.getTransferType()!=d2.getTransferType())
return false;
if(d1.getTransparency()!=d2.getTransparency())
return false;
return true;
}
示例3: getImageData
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
public ImageData getImageData(BufferedImage bufferedImage) {
DirectColorModel colorModel = (DirectColorModel) bufferedImage.getColorModel();
PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(),
colorModel.getBlueMask());
ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(),
colorModel.getPixelSize(), palette);
WritableRaster raster = bufferedImage.getRaster();
int[] pixelArray = new int[3];
for (int y = 0; y < data.height; y++) {
for (int x = 0; x < data.width; x++) {
raster.getPixel(x, y, pixelArray);
int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2]));
data.setPixel(x, y, pixel);
}
}
return data;
}
示例4: getImageData2
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
private static ImageData getImageData2(BufferedImage bufferedImage){
DirectColorModel colorModel = (DirectColorModel) bufferedImage.getColorModel();
//System.out.println("robot:" +colorModel.getRedMask() + " "+colorModel.getGreenMask() + " "+colorModel.getBlueMask());
PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(), colorModel
.getBlueMask());
ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel
.getPixelSize(), palette);
WritableRaster raster = bufferedImage.getRaster();
int[] pixelArray = new int[3];
for (int y = 0; y < data.height; y++) {
for (int x = 0; x < data.width; x++) {
raster.getPixel(x, y, pixelArray);
int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2]));
data.setPixel(x, y, pixel);
}
}
return data;
}
示例5: equals
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
/**
* This checks to see if two DirectColorModels are identical. Apparently the "equals" method in DirectColorModel doesn't really work.
*/
private static boolean equals(DirectColorModel d1, DirectColorModel d2) {
if (d1.getAlphaMask() != d2.getAlphaMask())
return false;
if (d1.getGreenMask() != d2.getGreenMask())
return false;
if (d1.getRedMask() != d2.getRedMask())
return false;
if (d1.getBlueMask() != d2.getBlueMask())
return false;
if (d1.getColorSpace() != d2.getColorSpace())
return false;
if (d1.isAlphaPremultiplied() != d2.isAlphaPremultiplied())
return false;
if (d1.getTransferType() != d2.getTransferType())
return false;
if (d1.getTransparency() != d2.getTransparency())
return false;
return true;
}
示例6: getRGB24
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
/** Gets 24-bit RGB pixels from a buffer. Returns null if conversion failed. */
protected int[] getRGB24(Buffer buf) {
if (buf.data instanceof int[]) {
return (int[]) buf.data;
}
if (buf.data instanceof BufferedImage) {
BufferedImage image = (BufferedImage) buf.data;
if (image.getColorModel() instanceof DirectColorModel) {
DirectColorModel dcm = (DirectColorModel) image.getColorModel();
if (dcm.getBlueMask() == 0xff && dcm.getGreenMask() == 0xff00 && dcm.getRedMask() == 0xff0000) {
if (image.getRaster().getDataBuffer() instanceof DataBufferInt) {
return ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
}
}
}
return image.getRGB(0, 0, //
outputFormat.get(WidthKey), outputFormat.get(HeightKey), //
null, 0, outputFormat.get(WidthKey));
}
return null;
}
示例7: getARGB32
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
/** Gets 32-bit ARGB pixels from a buffer. Returns null if conversion failed. */
protected int[] getARGB32(Buffer buf) {
if (buf.data instanceof int[]) {
return (int[]) buf.data;
}
if (buf.data instanceof BufferedImage) {
BufferedImage image = (BufferedImage) buf.data;
if (image.getColorModel() instanceof DirectColorModel) {
DirectColorModel dcm = (DirectColorModel) image.getColorModel();
if (dcm.getBlueMask() == 0xff && dcm.getGreenMask() == 0xff00 && dcm.getRedMask() == 0xff0000) {
if (image.getRaster().getDataBuffer() instanceof DataBufferInt) {
return ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
}
}
}
return image.getRGB(0, 0, //
outputFormat.get(WidthKey), outputFormat.get(HeightKey), //
null, 0, outputFormat.get(WidthKey));
}
return null;
}
示例8: createRaster
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
private void createRaster(){
try{
raster = cm.createCompatibleWritableRaster(width, height);
isIntRGB = false;
if(cm instanceof DirectColorModel){
DirectColorModel dcm = (DirectColorModel) cm;
if(dcm.getTransferType() == DataBuffer.TYPE_INT &&
dcm.getRedMask() == 0xff0000 &&
dcm.getGreenMask() == 0xff00 &&
dcm.getBlueMask() == 0xff){
isIntRGB = true;
}
}
}catch(Exception e){
cm = ColorModel.getRGBdefault();
raster = cm.createCompatibleWritableRaster(width, height);
isIntRGB = true;
}
}
示例9: createBufferedImage
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
void createBufferedImage() {
// REMIND: Be careful! Is this called everytime there is a
// startProduction? We only want to call it if it is new or
// there is an error
isDefaultBI = false;
try {
biRaster = cmodel.createCompatibleWritableRaster(width, height);
bimage = createImage(cmodel, biRaster,
cmodel.isAlphaPremultiplied(), null);
} catch (Exception e) {
// Create a default image
cmodel = ColorModel.getRGBdefault();
biRaster = cmodel.createCompatibleWritableRaster(width, height);
bimage = createImage(cmodel, biRaster, false, null);
}
int type = bimage.getType();
if ((cmodel == ColorModel.getRGBdefault()) ||
(type == BufferedImage.TYPE_INT_RGB) ||
(type == BufferedImage.TYPE_INT_ARGB_PRE)) {
isDefaultBI = true;
}
else if (cmodel instanceof DirectColorModel) {
DirectColorModel dcm = (DirectColorModel) cmodel;
if (dcm.getRedMask() == 0xff0000 &&
dcm.getGreenMask() == 0xff00 &&
dcm.getBlueMask() == 0xff) {
isDefaultBI = true;
}
}
}
示例10: GDIWindowSurfaceData
import java.awt.image.DirectColorModel; //导入方法依赖的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());
}
示例11: GDIWindowSurfaceData
import java.awt.image.DirectColorModel; //导入方法依赖的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());
}
示例12: checkCompatible
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
private void checkCompatible(ColorModel colorModel,
SampleModel sampleModel){
ColorSpace cs = colorModel.getColorSpace();
// Check that model is sRGB or linear RGB
if((!cs .equals (sRGB)) && (!cs .equals( lRGB)))
throw new IllegalArgumentException("Expected CS_sRGB or CS_LINEAR_RGB color model");
// Check ColorModel is of type DirectColorModel
if(!(colorModel instanceof DirectColorModel))
throw new IllegalArgumentException("colorModel should be an instance of DirectColorModel");
// Check transfer type
if(sampleModel.getDataType() != DataBuffer.TYPE_INT)
throw new IllegalArgumentException("colorModel's transferType should be DataBuffer.TYPE_INT");
// Check red, green, blue and alpha mask
DirectColorModel dcm = (DirectColorModel)colorModel;
if(dcm.getRedMask() != 0x00ff0000)
throw new IllegalArgumentException("red mask in source should be 0x00ff0000");
if(dcm.getGreenMask() != 0x0000ff00)
throw new IllegalArgumentException("green mask in source should be 0x0000ff00");
if(dcm.getBlueMask() != 0x000000ff)
throw new IllegalArgumentException("blue mask in source should be 0x000000ff");
if(dcm.getAlphaMask() != 0xff000000)
throw new IllegalArgumentException("alpha mask in source should be 0xff000000");
}
示例13: isCompatible
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
private boolean isCompatible(ColorModel colorModel,
SampleModel sampleModel){
ColorSpace cs = colorModel.getColorSpace();
// Check that model is sRGB or linear RGB
if((cs != ColorSpace.getInstance(ColorSpace.CS_sRGB))
&&
(cs != ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
return false;
// Check ColorModel is of type DirectColorModel
if(!(colorModel instanceof DirectColorModel))
return false;
// Check transfer type
if(sampleModel.getDataType() != DataBuffer.TYPE_INT)
return false;
// Check red, green, blue and alpha mask
DirectColorModel dcm = (DirectColorModel)colorModel;
if(dcm.getRedMask() != 0x00ff0000)
return false;
if(dcm.getGreenMask() != 0x0000ff00)
return false;
if(dcm.getBlueMask() != 0x000000ff)
return false;
if(dcm.getAlphaMask() != 0xff000000)
return false;
return true;
}
示例14: isRgbColorModel
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
private static boolean isRgbColorModel(ColorModel cm) {
if (cm instanceof DirectColorModel &&
cm.getTransferType() == DataBuffer.TYPE_INT) {
DirectColorModel directCM = (DirectColorModel) cm;
return directCM.getRedMask() == 0x00FF0000 &&
directCM.getGreenMask() == 0x0000FF00 &&
directCM.getBlueMask() == 0x000000FF &&
(directCM.getNumComponents() == 3 ||
directCM.getAlphaMask() == 0xFF000000);
}
return false;
}
示例15: isBgrColorModel
import java.awt.image.DirectColorModel; //导入方法依赖的package包/类
private static boolean isBgrColorModel(ColorModel cm) {
if (cm instanceof DirectColorModel &&
cm.getTransferType() == DataBuffer.TYPE_INT) {
DirectColorModel directCM = (DirectColorModel) cm;
return directCM.getRedMask() == 0x000000FF &&
directCM.getGreenMask() == 0x0000FF00 &&
directCM.getBlueMask() == 0x00FF0000 &&
(directCM.getNumComponents() == 3 ||
directCM.getAlphaMask() == 0xFF000000);
}
return false;
}