Java Code Examples for java.awt.Transparency#TRANSLUCENT
The following examples show how to use
java.awt.Transparency#TRANSLUCENT .
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: WGLVolatileSurfaceManager.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public WGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) { super(vImg, context); /* * We will attempt to accelerate this image only under the * following conditions: * - the image is opaque OR * - the image is translucent AND * - the GraphicsConfig supports the FBO extension OR * - the GraphicsConfig has a stored alpha channel */ int transparency = vImg.getTransparency(); WGLGraphicsConfig gc = (WGLGraphicsConfig)vImg.getGraphicsConfig(); accelerationEnabled = (transparency == Transparency.OPAQUE) || ((transparency == Transparency.TRANSLUCENT) && (gc.isCapPresent(CAPS_EXT_FBOBJECT) || gc.isCapPresent(CAPS_STORED_ALPHA))); }
Example 2
Source File: ImageTypeSpecifier.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static ColorModel createComponentCM(ColorSpace colorSpace, int numBands, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied) { int transparency = hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE; int[] numBits = new int[numBands]; int bits = DataBuffer.getDataTypeSize(dataType); for (int i = 0; i < numBands; i++) { numBits[i] = bits; } return new ComponentColorModel(colorSpace, numBits, hasAlpha, isAlphaPremultiplied, transparency, dataType); }
Example 3
Source File: BitmapResource.java From ghidra with Apache License 2.0 | 6 votes |
/** * @param buf * @return DataImage */ protected DataImage get32PlaneImage(MemBuffer buf) { // create the color model ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); int[] nBits = { 8, 8, 8, 8 }; int[] bOffs = { 0, 1, 2, 3 }; ColorModel colorModel = new ComponentColorModel(cs, nBits, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); int w = getWidth(); int h = getHeight(); WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h, w * 4, 4, bOffs, null); // create the image BufferedImage image = new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), null); byte[] dbuf = ((DataBufferByte) image.getRaster().getDataBuffer()).getData(); getPixelData(buf, dbuf); return new BitmapDataImage(image); }
Example 4
Source File: GLXGraphicsConfig.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 5
Source File: CGLGraphicsConfig.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 6
Source File: ImageTypeSpecifier.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
static ColorModel createComponentCM(ColorSpace colorSpace, int numBands, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied) { int transparency = hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE; int[] numBits = new int[numBands]; int bits = DataBuffer.getDataTypeSize(dataType); for (int i = 0; i < numBands; i++) { numBits[i] = bits; } return new ComponentColorModel(colorSpace, numBits, hasAlpha, isAlphaPremultiplied, transparency, dataType); }
Example 7
Source File: GLXVolatileSurfaceManager.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public GLXVolatileSurfaceManager(SunVolatileImage vImg, Object context) { super(vImg, context); /* * We will attempt to accelerate this image only under the * following conditions: * - the image is opaque OR * - the image is translucent AND * - the GraphicsConfig supports the FBO extension OR * - the GraphicsConfig has a stored alpha channel */ int transparency = vImg.getTransparency(); GLXGraphicsConfig gc = (GLXGraphicsConfig)vImg.getGraphicsConfig(); accelerationEnabled = (transparency == Transparency.OPAQUE) || ((transparency == Transparency.TRANSLUCENT) && (gc.isCapPresent(CAPS_EXT_FBOBJECT) || gc.isCapPresent(CAPS_STORED_ALPHA))); }
Example 8
Source File: D3DVolatileSurfaceManager.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public D3DVolatileSurfaceManager(SunVolatileImage vImg, Object context) { super(vImg, context); /* * We will attempt to accelerate this image only under the * following conditions: * - the image is opaque OR * - the image is translucent AND * - the GraphicsConfig supports the FBO extension OR * - the GraphicsConfig has a stored alpha channel */ int transparency = vImg.getTransparency(); D3DGraphicsDevice gd = (D3DGraphicsDevice) vImg.getGraphicsConfig().getDevice(); accelerationEnabled = (transparency == Transparency.OPAQUE) || (transparency == Transparency.TRANSLUCENT && (gd.isCapPresent(CAPS_RT_PLAIN_ALPHA) || gd.isCapPresent(CAPS_RT_TEXTURE_ALPHA))); }
Example 9
Source File: WGLGraphicsConfig.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 10
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 11
Source File: SunVolatileImage.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
protected SunVolatileImage(Component comp, GraphicsConfiguration graphicsConfig, int width, int height, Object context, int transparency, ImageCapabilities caps, int accType) { this.comp = comp; this.graphicsConfig = graphicsConfig; if (width <= 0 || height <= 0) { throw new IllegalArgumentException("Width (" + width + ")" + " and height (" + height + ") cannot be <= 0"); } this.width = width; this.height = height; this.forcedAccelSurfaceType = accType; if (!(transparency == Transparency.OPAQUE || transparency == Transparency.BITMASK || transparency == Transparency.TRANSLUCENT)) { throw new IllegalArgumentException("Unknown transparency type:" + transparency); } this.transparency = transparency; this.volSurfaceManager = createSurfaceManager(context, caps); SurfaceManager.setManager(this, volSurfaceManager); // post-construction initialization of the surface manager volSurfaceManager.initialize(); // clear the background volSurfaceManager.initContents(); }
Example 12
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 13
Source File: Destinations.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void init() { destroot = new Group.EnableSet(TestEnvironment.globaloptroot, "dest", "Output Destination Options"); new Screen(); new OffScreen(); if (GraphicsTests.hasGraphics2D) { if (ImageTests.hasCompatImage) { compatimgdestroot = new Group.EnableSet(destroot, "compatimg", "Compatible Image Destinations"); compatimgdestroot.setHorizontal(); new CompatImg(); new CompatImg(Transparency.OPAQUE); new CompatImg(Transparency.BITMASK); new CompatImg(Transparency.TRANSLUCENT); } if (ImageTests.hasVolatileImage) { new VolatileImg(); } bufimgdestroot = new Group.EnableSet(destroot, "bufimg", "BufferedImage Destinations"); new BufImg(BufferedImage.TYPE_INT_RGB); new BufImg(BufferedImage.TYPE_INT_ARGB); new BufImg(BufferedImage.TYPE_INT_ARGB_PRE); new BufImg(BufferedImage.TYPE_3BYTE_BGR); new BufImg(BufferedImage.TYPE_BYTE_INDEXED); new BufImg(BufferedImage.TYPE_BYTE_GRAY); new CustomImg(); } }
Example 14
Source File: CGLGraphicsConfig.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public Image createBackBuffer(final LWComponentPeer<?, ?> peer) { final Rectangle r = peer.getBounds(); // It is possible for the component to have size 0x0, adjust it to // be at least 1x1 to avoid IAE final int w = Math.max(1, r.width); final int h = Math.max(1, r.height); final int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT : Transparency.OPAQUE; return new SunVolatileImage(this, w, h, transparency, null); }
Example 15
Source File: X11GraphicsConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static ComponentColorModel createABGRCCM() { ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); int[] nBits = {8, 8, 8, 8}; int[] bOffs = {3, 2, 1, 0}; return new ComponentColorModel(cs, nBits, true, true, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); }
Example 16
Source File: XRSurfaceDataProxy.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSupportedOperation(SurfaceData srcData, int txtype, CompositeType comp, Color bgColor) { return (bgColor == null || transparency == Transparency.TRANSLUCENT); }
Example 17
Source File: CGLLayer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public int getTransparency() { return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT; }
Example 18
Source File: ImageTypeSpecifier.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public Grayscale(int bits, int dataType, boolean isSigned, boolean hasAlpha, boolean isAlphaPremultiplied) { if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16) { throw new IllegalArgumentException("Bad value for bits!"); } if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT && dataType != DataBuffer.TYPE_USHORT) { throw new IllegalArgumentException ("Bad value for dataType!"); } if (bits > 8 && dataType == DataBuffer.TYPE_BYTE) { throw new IllegalArgumentException ("Too many bits for dataType!"); } this.bits = bits; this.dataType = dataType; this.isSigned = isSigned; this.hasAlpha = hasAlpha; this.isAlphaPremultiplied = isAlphaPremultiplied; ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY); if ((bits == 8 && dataType == DataBuffer.TYPE_BYTE) || (bits == 16 && (dataType == DataBuffer.TYPE_SHORT || dataType == DataBuffer.TYPE_USHORT))) { // Use component color model & sample model int numBands = hasAlpha ? 2 : 1; int transparency = hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE; int[] nBits = new int[numBands]; nBits[0] = bits; if (numBands == 2) { nBits[1] = bits; } this.colorModel = new ComponentColorModel(colorSpace, nBits, hasAlpha, isAlphaPremultiplied, transparency, dataType); int[] bandOffsets = new int[numBands]; bandOffsets[0] = 0; if (numBands == 2) { bandOffsets[1] = 1; } int w = 1; int h = 1; this.sampleModel = new PixelInterleavedSampleModel(dataType, w, h, numBands, w*numBands, bandOffsets); } else { int numEntries = 1 << bits; byte[] arr = new byte[numEntries]; for (int i = 0; i < numEntries; i++) { arr[i] = (byte)(i*255/(numEntries - 1)); } this.colorModel = new IndexColorModel(bits, numEntries, arr, arr, arr); this.sampleModel = new MultiPixelPackedSampleModel(dataType, 1, 1, bits); } }
Example 19
Source File: XRSurfaceDataProxy.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSupportedOperation(SurfaceData srcData, int txtype, CompositeType comp, Color bgColor) { return (bgColor == null || transparency == Transparency.TRANSLUCENT); }
Example 20
Source File: DirectColorModel.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Constructs a <code>DirectColorModel</code> from the specified * parameters. Color components are in the specified * <code>ColorSpace</code>, which must be of type ColorSpace.TYPE_RGB * and have minimum normalized component values which are all 0.0 * and maximum values which are all 1.0. * The masks specify which bits in an <code>int</code> pixel * representation contain the red, green and blue color samples and * the alpha sample, if present. If <code>amask</code> is 0, pixel * values do not contain alpha information and all pixels are treated * as opaque, which means that alpha = 1.0. 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 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 value is * Transparency.OPAQUE, if no alpha is present, or * Transparency.TRANSLUCENT otherwise. The transfer type * is the type of primitive array used to represent pixel values and * must be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or * DataBuffer.TYPE_INT. * @param space the specified <code>ColorSpace</code> * @param bits the number of bits in the pixel values; for example, * the sum of the number of bits in the masks. * @param rmask specifies a mask indicating which bits in an * integer pixel contain the red component * @param gmask specifies a mask indicating which bits in an * integer pixel contain the green component * @param bmask specifies a mask indicating which bits in an * integer pixel contain the blue component * @param amask specifies a mask indicating which bits in an * integer pixel contain the alpha component * @param isAlphaPremultiplied <code>true</code> if color samples are * premultiplied by the alpha sample; <code>false</code> otherwise * @param transferType the type of array used to represent pixel values * @throws IllegalArgumentException if <code>space</code> is not a * TYPE_RGB space or if the min/max normalized component * values are not 0.0/1.0. */ public DirectColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int transferType) { super (space, bits, rmask, gmask, bmask, amask, isAlphaPremultiplied, amask == 0 ? Transparency.OPAQUE : Transparency.TRANSLUCENT, transferType); if (ColorModel.isLinearRGBspace(colorSpace)) { is_LinearRGB = true; if (maxBits <= 8) { lRGBprecision = 8; tosRGB8LUT = ColorModel.getLinearRGB8TosRGB8LUT(); fromsRGB8LUT8 = ColorModel.getsRGB8ToLinearRGB8LUT(); } else { lRGBprecision = 16; tosRGB8LUT = ColorModel.getLinearRGB16TosRGB8LUT(); fromsRGB8LUT16 = ColorModel.getsRGB8ToLinearRGB16LUT(); } } else if (!is_sRGB) { for (int i = 0; i < 3; i++) { // super constructor checks that space is TYPE_RGB // check here that min/max are all 0.0/1.0 if ((space.getMinValue(i) != 0.0f) || (space.getMaxValue(i) != 1.0f)) { throw new IllegalArgumentException( "Illegal min/max RGB component value"); } } } setFields(); }