java.awt.Transparency Java Examples

The following examples show how to use java.awt.Transparency. 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: X11VolatileSurfaceManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a pixmap-based SurfaceData object
 */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;

    try {
        X11GraphicsConfig gc = (X11GraphicsConfig)vImg.getGraphicsConfig();
        ColorModel cm = gc.getColorModel();
        long drawable = 0;
        if (context instanceof Long) {
            drawable = ((Long)context).longValue();
        }
        sData = X11SurfaceData.createData(gc,
                                          vImg.getWidth(),
                                          vImg.getHeight(),
                                          cm, vImg, drawable,
                                          Transparency.OPAQUE);
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }

    return sData;
}
 
Example #2
Source File: SimpleManagedImage.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the custom buffered image, which mostly identical to
 * BufferedImage.(w,h,TYPE_3BYTE_BGR), but uses the bigger scanlineStride.
 * This means that the raster will have gaps, between the rows.
 */
private static BufferedImage makeCustomManagedBI() {
    int w = 511, h = 255;
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    int[] nBits = {8, 8, 8};
    int[] bOffs = {2, 1, 0};
    ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false,
                                                    Transparency.OPAQUE,
                                                    DataBuffer.TYPE_BYTE);
    WritableRaster raster =
            Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h,
                                           w * 3 + 2, 3, bOffs, null);
    BufferedImage bi = new BufferedImage(colorModel, raster, true, null);
    SunWritableRaster.makeTrackable(raster.getDataBuffer());
    SunWritableRaster.markDirty(bi);
    return bi;
}
 
Example #3
Source File: CGLGraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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: GLXVolatileSurfaceManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #5
Source File: D3DGraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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: D3DSurfaceData.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private boolean initSurfaceNow() {
    boolean isOpaque = (getTransparency() == Transparency.OPAQUE);
    switch (type) {
        case RT_PLAIN:
            return initRTSurface(getNativeOps(), isOpaque);
        case TEXTURE:
            return initTexture(getNativeOps(), false/*isRTT*/, isOpaque);
        case RT_TEXTURE:
            return initTexture(getNativeOps(), true/*isRTT*/,  isOpaque);
        // REMIND: we may want to pass the exact type to the native
        // level here so that we could choose the right presentation
        // interval for the frontbuffer (immediate vs v-synced)
        case WINDOW:
        case FLIP_BACKBUFFER:
            return initFlipBackbuffer(getNativeOps(), peer.getData(),
                                      backBuffersNum, swapEffect,
                                      syncType.id());
        default:
            return false;
    }
}
 
Example #7
Source File: D3DGraphicsConfig.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 #8
Source File: DrawImage.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected boolean scaleSurfaceData(SunGraphics2D sg,
                                   Region clipRegion,
                                   SurfaceData srcData,
                                   SurfaceData dstData,
                                   SurfaceType srcType,
                                   SurfaceType dstType,
                                   int sx1, int sy1,
                                   int sx2, int sy2,
                                   double dx1, double dy1,
                                   double dx2, double dy2)
{
    CompositeType comp = sg.imageComp;
    if (CompositeType.SrcOverNoEa.equals(comp) &&
        (srcData.getTransparency() == Transparency.OPAQUE))
    {
        comp = CompositeType.SrcNoEa;
    }

    ScaledBlit blit = ScaledBlit.getFromCache(srcType, comp, dstType);
    if (blit != null) {
        blit.Scale(srcData, dstData, sg.composite, clipRegion,
                   sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
        return true;
    }
    return false;
}
 
Example #9
Source File: D3DRenderer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
void copyArea(SunGraphics2D sg2d,
              int x, int y, int w, int h, int dx, int dy)
{
    rq.lock();
    try {
        int ctxflags =
            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
                D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
        D3DSurfaceData dstData;
        try {
            dstData = (D3DSurfaceData)sg2d.surfaceData;
        } catch (ClassCastException e) {
            throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
        }
        D3DContext.validateContext(dstData, dstData,
                                   sg2d.getCompClip(), sg2d.composite,
                                   null, null, null, ctxflags);

        rq.ensureCapacity(28);
        buf.putInt(COPY_AREA);
        buf.putInt(x).putInt(y).putInt(w).putInt(h);
        buf.putInt(dx).putInt(dy);
    } finally {
        rq.unlock();
    }
}
 
Example #10
Source File: IncorrectManagedImageSourceOffset.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the custom buffered image, which mostly identical to
 * BufferedImage.(w,h,TYPE_3BYTE_BGR), but uses the bigger scanlineStride.
 * This means that the raster will have gaps, between the rows.
 */
private static BufferedImage makeCustomManagedBI() {
    int w = 511, h = 255;
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    int[] nBits = {8, 8, 8};
    int[] bOffs = {2, 1, 0};
    ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false,
                                                    Transparency.OPAQUE,
                                                    DataBuffer.TYPE_BYTE);
    WritableRaster raster =
            Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h,
                                           w * 3 + 2, 3, bOffs, null);
    BufferedImage bi = new BufferedImage(colorModel, raster, true, null);
    SunWritableRaster.makeTrackable(raster.getDataBuffer());
    SunWritableRaster.markDirty(bi);
    return bi;
}
 
Example #11
Source File: WGLVolatileSurfaceManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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 #12
Source File: BitmapResource.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * @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 #13
Source File: D3DRenderer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void copyArea(SunGraphics2D sg2d,
              int x, int y, int w, int h, int dx, int dy)
{
    rq.lock();
    try {
        int ctxflags =
            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
                D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
        D3DSurfaceData dstData;
        try {
            dstData = (D3DSurfaceData)sg2d.surfaceData;
        } catch (ClassCastException e) {
            throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
        }
        D3DContext.validateContext(dstData, dstData,
                                   sg2d.getCompClip(), sg2d.composite,
                                   null, null, null, ctxflags);

        rq.ensureCapacity(28);
        buf.putInt(COPY_AREA);
        buf.putInt(x).putInt(y).putInt(w).putInt(h);
        buf.putInt(dx).putInt(dy);
    } finally {
        rq.unlock();
    }
}
 
Example #14
Source File: D3DVolatileSurfaceManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #15
Source File: GLXVolatileSurfaceManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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 #16
Source File: ImageTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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 #17
Source File: BMPSubsamplingTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private BufferedImage create3ByteImage(int[] nBits, int[] bOffs) {
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel colorModel =
        new ComponentColorModel(cs, nBits,
                                false, false,
                                Transparency.OPAQUE,
                                DataBuffer.TYPE_BYTE);
    WritableRaster raster =
        Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
                                       w, h,
                                       w*3, 3,
                                       bOffs, null);
    return new BufferedImage(colorModel, raster, false, null);
}
 
Example #18
Source File: CGLGraphicsConfig.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 #19
Source File: Win32GraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #20
Source File: Win32GraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new managed image of the given width and height
 * that is associated with the target Component.
 */
public Image createAcceleratedImage(Component target,
                                    int width, int height)
{
    ColorModel model = getColorModel(Transparency.OPAQUE);
    WritableRaster wr =
        model.createCompatibleWritableRaster(width, height);
    return new OffScreenImage(target, model, wr,
                              model.isAlphaPremultiplied());
}
 
Example #21
Source File: X11GraphicsConfig.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #22
Source File: GLXGraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 #23
Source File: WGLGraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 #24
Source File: PrinterGraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #25
Source File: SimpleUnmanagedImage.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the custom buffered image, which mostly identical to
 * BufferedImage.(w,h,TYPE_3BYTE_BGR), but uses the bigger scanlineStride.
 * This means that the raster will have gaps, between the rows.
 */
private static BufferedImage makeCustomUnmanagedBI() {
    int w = 511, h = 255;
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    int[] nBits = {8, 8, 8};
    int[] bOffs = {2, 1, 0};
    ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false,
                                                    Transparency.OPAQUE,
                                                    DataBuffer.TYPE_BYTE);
    WritableRaster raster =
            Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h,
                                           w * 3 + 2, 3, bOffs, null);
    return new BufferedImage(colorModel, raster, true, null);
}
 
Example #26
Source File: ColCvtAlpha.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) {
    BufferedImage src
        = new BufferedImage(1, 10, BufferedImage.TYPE_INT_ARGB);

    // Set src pixel values
    Color pelColor = new Color(100, 100, 100, 128);
    for (int i = 0; i < 10; i++) {
        src.setRGB(0, i, pelColor.getRGB());
    }

    ColorModel cm = new ComponentColorModel
        (ColorSpace.getInstance(ColorSpace.CS_GRAY),
         new int [] {8,8}, true,
         src.getColorModel().isAlphaPremultiplied(),
         Transparency.TRANSLUCENT,
         DataBuffer.TYPE_BYTE);

    SampleModel sm = new PixelInterleavedSampleModel
        (DataBuffer.TYPE_BYTE, 100, 100, 2, 200,
         new int [] { 0, 1 });

    WritableRaster wr = Raster.createWritableRaster(sm, new Point(0,0));

    BufferedImage dst =
        new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
    dst = dst.getSubimage(0, 0, 1, 10);

    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(src, dst);

    for (int i = 0; i < 10; i++) {
        if (((dst.getRGB(0, i) >> 24) & 0xff) != 128) {
            throw new RuntimeException(
                "Incorrect destination alpha value.");
        }
    }

}
 
Example #27
Source File: SourceClippingBlitTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static Image getBMImage(GraphicsConfiguration gc,
                        int w, int h)
{
    Image image =
        gc.createCompatibleImage(w, h, Transparency.BITMASK);
    initImage(gc, image);
    return image;
}
 
Example #28
Source File: X11GraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 #29
Source File: SourceClippingBlitTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static VolatileImage getVImage(GraphicsConfiguration gc,
                               int w, int h)
{
    VolatileImage image =
        gc.createCompatibleVolatileImage(w, h, Transparency.OPAQUE);
    image.validate(gc);
    initImage(gc, image);
    return image;
}
 
Example #30
Source File: SunVolatileImage.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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();
}