Java Code Examples for java.awt.Transparency#BITMASK
The following examples show how to use
java.awt.Transparency#BITMASK .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: D3DGraphicsConfig.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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; } }
Example 2
Source File: CGLGraphicsConfig.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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; } }
Example 3
Source File: GLXGraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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; } }
Example 4
Source File: WGLGraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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; } }
Example 5
Source File: ImageTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public TriStateImageType(Group parent, String nodename, String desc, int transparency) { super(parent, nodename, desc); setHorizontal(); new DrawableImage(this, Transparency.OPAQUE, true); new DrawableImage(this, Transparency.BITMASK, (transparency != Transparency.OPAQUE)); new DrawableImage(this, Transparency.TRANSLUCENT, (transparency == Transparency.TRANSLUCENT)); }
Example 6
Source File: WGLGraphicsConfig.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} * * @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage */ @Override public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency, int type) { if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED || transparency == Transparency.BITMASK) { return null; } if (type == FBOBJECT) { if (!isCapPresent(CAPS_EXT_FBOBJECT)) { return null; } } else if (type == PBUFFER) { boolean isOpaque = transparency == Transparency.OPAQUE; if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) { return null; } } SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height, transparency, type); Surface sd = vi.getDestSurface(); if (!(sd instanceof AccelSurface) || ((AccelSurface)sd).getType() != type) { vi.flush(); vi = null; } return vi; }
Example 7
Source File: ImageTests.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public TriStateImageType(Group parent, String nodename, String desc, int transparency) { super(parent, nodename, desc); setHorizontal(); new DrawableImage(this, Transparency.OPAQUE, true); new DrawableImage(this, Transparency.BITMASK, (transparency != Transparency.OPAQUE)); new DrawableImage(this, Transparency.TRANSLUCENT, (transparency == Transparency.TRANSLUCENT)); }
Example 8
Source File: PrinterGraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 9
Source File: Win32GraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 10
Source File: WGLGraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} * * @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage */ @Override public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency, int type) { if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED || transparency == Transparency.BITMASK) { return null; } if (type == FBOBJECT) { if (!isCapPresent(CAPS_EXT_FBOBJECT)) { return null; } } else if (type == PBUFFER) { boolean isOpaque = transparency == Transparency.OPAQUE; if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) { return null; } } SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height, transparency, type); Surface sd = vi.getDestSurface(); if (!(sd instanceof AccelSurface) || ((AccelSurface)sd).getType() != type) { vi.flush(); vi = null; } return vi; }
Example 11
Source File: CGLGraphicsConfig.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency, int type) { if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED || transparency == Transparency.BITMASK) { return null; } if (type == FBOBJECT) { if (!isCapPresent(CAPS_EXT_FBOBJECT)) { return null; } } else if (type == PBUFFER) { boolean isOpaque = transparency == Transparency.OPAQUE; if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) { return null; } } SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height, transparency, type); Surface sd = vi.getDestSurface(); if (!(sd instanceof AccelSurface) || ((AccelSurface)sd).getType() != type) { vi.flush(); vi = null; } return vi; }
Example 12
Source File: CGLGraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency, int type) { if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED || transparency == Transparency.BITMASK) { return null; } if (type == FBOBJECT) { if (!isCapPresent(CAPS_EXT_FBOBJECT)) { return null; } } else if (type == PBUFFER) { boolean isOpaque = transparency == Transparency.OPAQUE; if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) { return null; } } SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height, transparency, type); Surface sd = vi.getDestSurface(); if (!(sd instanceof AccelSurface) || ((AccelSurface)sd).getType() != type) { vi.flush(); vi = null; } return vi; }
Example 13
Source File: D3DGraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} * * @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage */ @Override public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency, int type) { if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED || transparency == Transparency.BITMASK) { return null; } boolean isOpaque = transparency == Transparency.OPAQUE; if (type == RT_TEXTURE) { int cap = isOpaque ? CAPS_RT_TEXTURE_OPAQUE : CAPS_RT_TEXTURE_ALPHA; if (!device.isCapPresent(cap)) { return null; } } else if (type == RT_PLAIN) { if (!isOpaque && !device.isCapPresent(CAPS_RT_PLAIN_ALPHA)) { return null; } } SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height, transparency, type); Surface sd = vi.getDestSurface(); if (!(sd instanceof AccelSurface) || ((AccelSurface)sd).getType() != type) { vi.flush(); vi = null; } return vi; }
Example 14
Source File: X11SurfaceData.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static SurfaceType getSurfaceType(X11GraphicsConfig gc, int transparency, boolean pixmapSurface) { boolean transparent = (transparency == Transparency.BITMASK); SurfaceType sType; ColorModel cm = gc.getColorModel(); switch (cm.getPixelSize()) { case 24: if (gc.getBitsPerPixel() == 24) { if (cm instanceof DirectColorModel) { // 4517321: We will always use ThreeByteBgr for 24 bpp // surfaces, regardless of the pixel masks reported by // X11. Despite ambiguity in the X11 spec in how 24 bpp // surfaces are treated, it appears that the best // SurfaceType for these configurations (including // some Matrox Millenium and ATI Radeon boards) is // ThreeByteBgr. sType = transparent ? X11SurfaceData.ThreeByteBgrX11_BM : X11SurfaceData.ThreeByteBgrX11; } else { throw new sun.java2d.InvalidPipeException("Unsupported bit " + "depth/cm combo: " + cm.getPixelSize() + ", " + cm); } break; } // Fall through for 32 bit case case 32: if (cm instanceof DirectColorModel) { if (((SunToolkit)java.awt.Toolkit.getDefaultToolkit() ).isTranslucencyCapable(gc) && !pixmapSurface) { sType = X11SurfaceData.IntArgbPreX11; } else { if (((DirectColorModel)cm).getRedMask() == 0xff0000) { sType = transparent ? X11SurfaceData.IntRgbX11_BM : X11SurfaceData.IntRgbX11; } else { sType = transparent ? X11SurfaceData.IntBgrX11_BM : X11SurfaceData.IntBgrX11; } } } else if (cm instanceof ComponentColorModel) { sType = X11SurfaceData.FourByteAbgrPreX11; } else { throw new sun.java2d.InvalidPipeException("Unsupported bit " + "depth/cm combo: " + cm.getPixelSize() + ", " + cm); } break; case 15: sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11; break; case 16: if ((cm instanceof DirectColorModel) && (((DirectColorModel)cm).getGreenMask() == 0x3e0)) { // fix for 4352984: Riva128 on Linux sType = transparent ? X11SurfaceData.UShort555RgbX11_BM : X11SurfaceData.UShort555RgbX11; } else { sType = transparent ? X11SurfaceData.UShort565RgbX11_BM : X11SurfaceData.UShort565RgbX11; } break; case 12: if (cm instanceof IndexColorModel) { sType = transparent ? X11SurfaceData.UShortIndexedX11_BM : X11SurfaceData.UShortIndexedX11; } else { throw new sun.java2d.InvalidPipeException("Unsupported bit " + "depth: " + cm.getPixelSize() + " cm="+cm); } break; case 8: if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY && cm instanceof ComponentColorModel) { sType = transparent ? X11SurfaceData.ByteGrayX11_BM : X11SurfaceData.ByteGrayX11; } else if (cm instanceof IndexColorModel && isOpaqueGray((IndexColorModel)cm)) { sType = transparent ? X11SurfaceData.Index8GrayX11_BM : X11SurfaceData.Index8GrayX11; } else { sType = transparent ? X11SurfaceData.ByteIndexedX11_BM : X11SurfaceData.ByteIndexedOpaqueX11; } break; default: throw new sun.java2d.InvalidPipeException("Unsupported bit " + "depth: " + cm.getPixelSize()); } return sType; }
Example 15
Source File: ImageTests.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public BmByteIndexBufImg() { super(bufimgsrcroot, "ByteIndexedBm", "8-bit Transparent Indexed Image", Transparency.BITMASK); }
Example 16
Source File: X11SurfaceDataProxy.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
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; }
Example 17
Source File: X11SurfaceDataProxy.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public int getTransparency() { return Transparency.BITMASK; }
Example 18
Source File: ImageTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public BmByteIndexBufImg() { super(bufimgsrcroot, "ByteIndexedBm", "8-bit Transparent Indexed Image", Transparency.BITMASK); }
Example 19
Source File: PackedColorModel.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Constructs a <code>PackedColorModel</code> from the specified * masks which indicate which bits in an <code>int</code> pixel * representation contain the alpha, red, green and blue color samples. * Color components are in the specified <code>ColorSpace</code>, which * must be of type ColorSpace.TYPE_RGB. All of the bits in each * mask must be contiguous and fit in the specified number of * least significant bits of an <code>int</code> pixel representation. If * <code>amask</code> is 0, there is no alpha. If there is alpha, * the <code>boolean</code> <code>isAlphaPremultiplied</code> * specifies how to interpret color and alpha samples * in pixel values. If the <code>boolean</code> is <code>true</code>, * color samples are assumed to have been multiplied by the alpha sample. * The transparency, <code>trans</code>, specifies what alpha values * can be represented by this color model. * The transfer type is the type of primitive array used to represent * pixel values. * @param space the specified <code>ColorSpace</code> * @param bits the number of bits in the pixel values * @param rmask specifies the mask representing * the bits of the pixel values that represent the red * color component * @param gmask specifies the mask representing * the bits of the pixel values that represent the green * color component * @param bmask specifies the mask representing * the bits of the pixel values that represent * the blue color component * @param amask specifies the mask representing * the bits of the pixel values that represent * the alpha component * @param isAlphaPremultiplied <code>true</code> if color samples are * premultiplied by the alpha sample; <code>false</code> otherwise * @param trans specifies the alpha value that can be represented by * this color model * @param transferType the type of array used to represent pixel values * @throws IllegalArgumentException if <code>space</code> is not a * TYPE_RGB space * @see ColorSpace */ public PackedColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int trans, int transferType) { super (bits, PackedColorModel.createBitsArray(rmask, gmask, bmask, amask), space, (amask == 0 ? false : true), isAlphaPremultiplied, trans, transferType); if (space.getType() != ColorSpace.TYPE_RGB) { throw new IllegalArgumentException("ColorSpace must be TYPE_RGB."); } maskArray = new int[numComponents]; maskOffsets = new int[numComponents]; scaleFactors = new float[numComponents]; DecomposeMask(rmask, 0, "red"); DecomposeMask(gmask, 1, "green"); DecomposeMask(bmask, 2, "blue"); if (amask != 0) { DecomposeMask(amask, 3, "alpha"); if (nBits[3] == 1) { transparency = Transparency.BITMASK; } } }
Example 20
Source File: PackedColorModel.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Constructs a <code>PackedColorModel</code> from a color mask array, * which specifies which bits in an <code>int</code> pixel representation * contain each of the color samples, and an alpha mask. Color * components are in the specified <code>ColorSpace</code>. The length of * <code>colorMaskArray</code> should be the number of components in * the <code>ColorSpace</code>. All of the bits in each mask * must be contiguous and fit in the specified number of least significant * bits of an <code>int</code> pixel representation. If the * <code>alphaMask</code> is 0, there is no alpha. If there is alpha, * the <code>boolean</code> <code>isAlphaPremultiplied</code> specifies * how to interpret color and alpha samples in pixel values. If the * <code>boolean</code> is <code>true</code>, color samples are assumed * to have been multiplied by the alpha sample. The transparency, * <code>trans</code>, specifies what alpha values can be represented * by this color model. The transfer type is the type of primitive * array used to represent pixel values. * @param space the specified <code>ColorSpace</code> * @param bits the number of bits in the pixel values * @param colorMaskArray array that specifies the masks representing * the bits of the pixel values that represent the color * components * @param alphaMask specifies the mask representing * the bits of the pixel values that represent the alpha * component * @param isAlphaPremultiplied <code>true</code> if color samples are * premultiplied by the alpha sample; <code>false</code> otherwise * @param trans specifies the alpha value that can be represented by * this color model * @param transferType the type of array used to represent pixel values * @throws IllegalArgumentException if <code>bits</code> is less than * 1 or greater than 32 */ public PackedColorModel (ColorSpace space, int bits, int[] colorMaskArray, int alphaMask, boolean isAlphaPremultiplied, int trans, int transferType) { super(bits, PackedColorModel.createBitsArray(colorMaskArray, alphaMask), space, (alphaMask == 0 ? false : true), isAlphaPremultiplied, trans, transferType); if (bits < 1 || bits > 32) { throw new IllegalArgumentException("Number of bits must be between" +" 1 and 32."); } maskArray = new int[numComponents]; maskOffsets = new int[numComponents]; scaleFactors = new float[numComponents]; for (int i=0; i < numColorComponents; i++) { // Get the mask offset and #bits DecomposeMask(colorMaskArray[i], i, space.getName(i)); } if (alphaMask != 0) { DecomposeMask(alphaMask, numColorComponents, "alpha"); if (nBits[numComponents-1] == 1) { transparency = Transparency.BITMASK; } } }