java.awt.Transparency#TRANSLUCENT源码实例Demo

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

源代码1 项目: TencentKona-8   文件: WGLVolatileSurfaceManager.java
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)));
}
 
源代码2 项目: TencentKona-8   文件: 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;
    }
}
 
源代码3 项目: TencentKona-8   文件: D3DVolatileSurfaceManager.java
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)));
}
 
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)));
}
 
源代码5 项目: dragonwell8_jdk   文件: ImageTypeSpecifier.java
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);
}
 
源代码6 项目: dragonwell8_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;
    }
}
 
源代码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 项目: ghidra   文件: BitmapResource.java
/**
 * @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);
}
 
源代码9 项目: TencentKona-8   文件: ImageTypeSpecifier.java
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);
}
 
源代码10 项目: dragonwell8_jdk   文件: X11GraphicsConfig.java
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);
}
 
源代码11 项目: dragonwell8_jdk   文件: Destinations.java
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();
    }
}
 
源代码12 项目: TencentKona-8   文件: ImageTests.java
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));
}
 
源代码13 项目: dragonwell8_jdk   文件: SunVolatileImage.java
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();
}
 
源代码14 项目: dragonwell8_jdk   文件: Win32GraphicsConfig.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;
    }
}
 
源代码15 项目: TencentKona-8   文件: CGLGraphicsConfig.java
@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);
}
 
源代码16 项目: TencentKona-8   文件: CGLLayer.java
public int getTransparency() {
    return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
}
 
源代码17 项目: TencentKona-8   文件: XRSurfaceDataProxy.java
@Override
public boolean isSupportedOperation(SurfaceData srcData, int txtype,
        CompositeType comp, Color bgColor) {
    return (bgColor == null || transparency == Transparency.TRANSLUCENT);
}
 
源代码18 项目: TencentKona-8   文件: ImageTypeSpecifier.java
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);
    }
}
 
源代码19 项目: dragonwell8_jdk   文件: XRSurfaceDataProxy.java
@Override
public boolean isSupportedOperation(SurfaceData srcData, int txtype,
        CompositeType comp, Color bgColor) {
    return (bgColor == null || transparency == Transparency.TRANSLUCENT);
}
 
源代码20 项目: dragonwell8_jdk   文件: DirectColorModel.java
/**
 * 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&nbsp;=&nbsp;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();
}
 
 方法所在类
 同类方法