java.awt.image.PixelInterleavedSampleModel#java.awt.image.DirectColorModel源码实例Demo

下面列出了java.awt.image.PixelInterleavedSampleModel#java.awt.image.DirectColorModel 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: amidst   文件: BiomeExporter.java
public CustomRenderedImage(
		int worldX,
		int worldY,
		int width,
		int height,
		BiomeProfileSelection biomeProfileSelection,
		BiomeDataOracle biomeDataOracle,
		boolean useQuarterResolution,
		ProgressReporter<Entry<ProgressEntryType, Integer>> progressReporter) {
	this.useQuarterResolution = useQuarterResolution;
	this.resolutionFactor = useQuarterResolution ? 4 : 1;
	this.worldX = worldX;
	this.worldY = worldY;
	this.width = width;
	this.height = height;
	this.colorModel = new DirectColorModel(24, BITMASKS[0], BITMASKS[1], BITMASKS[2]);
	this.sampleModel = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, width, height, BITMASKS);
	this.biomeProfileSelection = biomeProfileSelection;
	this.biomeDataOracle = biomeDataOracle;
	this.progressReporter = progressReporter;
}
 
源代码2 项目: jdk8u-jdk   文件: BufferedImageGraphicsConfig.java
/**
 * Returns the color model associated with this configuration that
 * supports the specified transparency.
 */
public ColorModel getColorModel(int transparency) {

    if (model.getTransparency() == transparency) {
        return model;
    }
    switch (transparency) {
    case Transparency.OPAQUE:
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        return ColorModel.getRGBdefault();
    default:
        return null;
    }
}
 
源代码3 项目: pumpernickel   文件: ImageLoader.java
/**
 * 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;
}
 
源代码4 项目: jdk8u-jdk   文件: CGLGraphicsConfig.java
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
源代码5 项目: AndroidRobot   文件: DeviceSocketClient.java
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;
}
 
源代码6 项目: openjdk-jdk8u-backup   文件: CGLGraphicsConfig.java
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
源代码7 项目: TencentKona-8   文件: GLXGraphicsConfig.java
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
源代码8 项目: jdk8u-dev-jdk   文件: GLXGraphicsConfig.java
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
源代码9 项目: jpexs-decompiler   文件: AbstractVideoCodec.java
/** 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;
}
 
源代码10 项目: openjdk-8-source   文件: WGLGraphicsConfig.java
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
源代码11 项目: openjdk-8-source   文件: GLXGraphicsConfig.java
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
源代码12 项目: jdk8u60   文件: D3DGraphicsConfig.java
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
源代码13 项目: openjdk-jdk9   文件: PackedColorModelEqualsTest.java
private static void testConstructor2() {
    /*
     * verify equality with constructor
     * DirectColorModel(ColorSpace space, int bits, int rmask, int gmask,
     * int bmask, int amask, boolean isAlphaPremultiplied, int transferType)
     */
    DirectColorModel model1 =
        new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF,
                false, DataBuffer.TYPE_BYTE);
    DirectColorModel model2 =
        new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF,
                false, DataBuffer.TYPE_BYTE);
    verifyEquals(model1, model2);
}
 
源代码14 项目: openjdk-jdk9   文件: PackedColorModelEqualsTest.java
private static void testMaskArrayEquality() {
    /*
     * Test with different maskArray values, since PackedColorModel
     * is abstract we use subclass DirectColorModel.
     */
    DirectColorModel model1 =
        new DirectColorModel(24, 0x00FF0000, 0x0000FF00, 0x000000FF);
    DirectColorModel model2 =
        new DirectColorModel(24, 0x000000FF, 0x0000FF00, 0x00FF0000);
    if (model1.equals(model2)) {
        throw new RuntimeException("equals() method is determining"
                + " ColorMap equality improperly");
    }
    if (model2.equals(model1)) {
        throw new RuntimeException("equals() method is determining"
                + " ColorMap equality improperly");
    }
}
 
源代码15 项目: hottub   文件: BufferedImageGraphicsConfig.java
/**
 * Returns the color model associated with this configuration that
 * supports the specified transparency.
 */
public ColorModel getColorModel(int transparency) {

    if (model.getTransparency() == transparency) {
        return model;
    }
    switch (transparency) {
    case Transparency.OPAQUE:
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        return ColorModel.getRGBdefault();
    default:
        return null;
    }
}
 
源代码16 项目: webp-imageio   文件: WebP.java
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;
}
 
源代码17 项目: openjdk-jdk8u   文件: CGLGraphicsConfig.java
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
源代码18 项目: hottub   文件: X11GraphicsConfig.java
/**
 * Returns the color model associated with this configuration that
 * supports the specified transparency.
 */
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        return getColorModel();
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        return ColorModel.getRGBdefault();
    default:
        return null;
    }
}
 
源代码19 项目: jdk8u-jdk   文件: GDIWindowSurfaceData.java
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());
}
 
源代码20 项目: jdk8u-jdk   文件: ImageRepresentation.java
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;
        }
    }
}
 
源代码21 项目: dragonwell8_jdk   文件: ImageRepresentation.java
public BufferedImage getOpaqueRGBImage() {
    if (bimage.getType() == BufferedImage.TYPE_INT_ARGB) {
        int w = bimage.getWidth();
        int h = bimage.getHeight();
        int size = w * h;

        // Note that we steal the data array here, but only for reading...
        DataBufferInt db = (DataBufferInt)biRaster.getDataBuffer();
        int[] pixels = SunWritableRaster.stealData(db, 0);

        for (int i = 0; i < size; i++) {
            if ((pixels[i] >>> 24) != 0xff) {
                return bimage;
            }
        }

        ColorModel opModel = new DirectColorModel(24,
                                                  0x00ff0000,
                                                  0x0000ff00,
                                                  0x000000ff);

        int bandmasks[] = {0x00ff0000, 0x0000ff00, 0x000000ff};
        WritableRaster opRaster = Raster.createPackedRaster(db, w, h, w,
                                                            bandmasks,
                                                            null);

        try {
            BufferedImage opImage = createImage(opModel, opRaster,
                                                false, null);
            return opImage;
        } catch (Exception e) {
            return bimage;
        }
    }
    return bimage;
}
 
源代码22 项目: jdk8u-dev-jdk   文件: PrinterGraphicsConfig.java
/**
 * Returns the color model associated with this configuration that
 * supports the specified transparency.
 */
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        return getColorModel();
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        return ColorModel.getRGBdefault();
    default:
        return null;
    }
}
 
源代码23 项目: jdk8u-dev-jdk   文件: X11GraphicsConfig.java
/**
 * Returns the color model associated with this configuration that
 * supports the specified transparency.
 */
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        return getColorModel();
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        return ColorModel.getRGBdefault();
    default:
        return null;
    }
}
 
源代码24 项目: openjdk-8-source   文件: X11GraphicsConfig.java
/**
 * Returns the color model associated with this configuration that
 * supports the specified transparency.
 */
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        return getColorModel();
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        return ColorModel.getRGBdefault();
    default:
        return null;
    }
}
 
源代码25 项目: jdk8u_jdk   文件: CGLGraphicsConfig.java
@Override
public BufferedImage createCompatibleImage(int width, int height) {
    ColorModel model = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    WritableRaster
        raster = model.createCompatibleWritableRaster(width, height);
    return new BufferedImage(model, raster, model.isAlphaPremultiplied(),
                             null);
}
 
源代码26 项目: dragonwell8_jdk   文件: GDIWindowSurfaceData.java
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());
}
 
源代码27 项目: openjdk-jdk8u-backup   文件: ImageRepresentation.java
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;
        }
    }
}
 
源代码28 项目: dragonwell8_jdk   文件: GLXGraphicsConfig.java
@Override
public BufferedImage createCompatibleImage(int width, int height) {
    ColorModel model = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    WritableRaster
        raster = model.createCompatibleWritableRaster(width, height);
    return new BufferedImage(model, raster, model.isAlphaPremultiplied(),
                             null);
}
 
源代码29 项目: jdk8u_jdk   文件: GLXGraphicsConfig.java
@Override
public BufferedImage createCompatibleImage(int width, int height) {
    ColorModel model = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    WritableRaster
        raster = model.createCompatibleWritableRaster(width, height);
    return new BufferedImage(model, raster, model.isAlphaPremultiplied(),
                             null);
}
 
源代码30 项目: jdk8u_jdk   文件: TexturePaintContext.java
public static boolean isFilterableDCM(ColorModel cm) {
    if (cm instanceof DirectColorModel) {
        DirectColorModel dcm = (DirectColorModel) cm;
        return (isMaskOK(dcm.getAlphaMask(), true) &&
                isMaskOK(dcm.getRedMask(), false) &&
                isMaskOK(dcm.getGreenMask(), false) &&
                isMaskOK(dcm.getBlueMask(), false));
    }
    return false;
}