Search in sources :

Example 6 with ToolkitImage

use of sun.awt.image.ToolkitImage in project jdk8u_jdk by JetBrains.

the class DrawImage method copyImage.

public boolean copyImage(SunGraphics2D sg, Image img, int x, int y, Color bgColor, ImageObserver observer) {
    if (!(img instanceof ToolkitImage)) {
        return copyImage(sg, img, x, y, bgColor);
    } else {
        ToolkitImage sunimg = (ToolkitImage) img;
        if (!imageReady(sunimg, observer)) {
            return false;
        }
        ImageRepresentation ir = sunimg.getImageRep();
        return ir.drawToBufImage(sg, sunimg, x, y, bgColor, observer);
    }
}
Also used : ImageRepresentation(sun.awt.image.ImageRepresentation) ToolkitImage(sun.awt.image.ToolkitImage)

Example 7 with ToolkitImage

use of sun.awt.image.ToolkitImage in project jdk8u_jdk by JetBrains.

the class XIconWindow method setIconImage.

void setIconImage(Image img) {
    if (img == null) {
        //if image is null, reset to default image
        replaceImage(null);
        replaceMask(null);
    } else {
        //get image size
        int width;
        int height;
        if (img instanceof ToolkitImage) {
            ImageRepresentation ir = ((ToolkitImage) img).getImageRep();
            ir.reconstruct(ImageObserver.ALLBITS);
            width = ir.getWidth();
            height = ir.getHeight();
        } else {
            width = img.getWidth(null);
            height = img.getHeight(null);
        }
        Dimension iconSize = getIconSize(width, height);
        if (iconSize != null) {
            if (log.isLoggable(PlatformLogger.Level.FINEST)) {
                log.finest("Icon size: {0}", iconSize);
            }
            iconWidth = iconSize.width;
            iconHeight = iconSize.height;
        } else {
            log.finest("Error calculating image size");
            iconWidth = 0;
            iconHeight = 0;
        }
        replaceImage(img);
        replaceMask(img);
    }
    //create icon window and set XWMHints
    XToolkit.awtLock();
    try {
        AwtGraphicsConfigData adata = parent.getGraphicsConfigurationData();
        awtImageData awtImage = adata.get_awtImage(0);
        XVisualInfo visInfo = adata.get_awt_visInfo();
        XWMHints hints = parent.getWMHints();
        window = hints.get_icon_window();
        if (window == 0) {
            log.finest("Icon window wasn't set");
            XCreateWindowParams params = getDelayedParams();
            params.add(BORDER_PIXEL, Long.valueOf(XToolkit.getAwtDefaultFg()));
            params.add(BACKGROUND_PIXMAP, iconPixmap);
            params.add(COLORMAP, adata.get_awt_cmap());
            params.add(DEPTH, awtImage.get_Depth());
            params.add(VISUAL_CLASS, (int) XConstants.InputOutput);
            params.add(VISUAL, visInfo.get_visual());
            params.add(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWColormap | XConstants.CWBackPixmap);
            params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), visInfo.get_screen()));
            params.add(BOUNDS, new Rectangle(0, 0, iconWidth, iconHeight));
            params.remove(DELAYED);
            init(params);
            if (getWindow() == 0) {
                log.finest("Can't create new icon window");
            } else {
                log.finest("Created new icon window");
            }
        }
        if (getWindow() != 0) {
            XlibWrapper.XSetWindowBackgroundPixmap(XToolkit.getDisplay(), getWindow(), iconPixmap);
            XlibWrapper.XClearWindow(XToolkit.getDisplay(), getWindow());
        }
        // Provide both pixmap and window, WM or Taskbar will use the one they find more appropriate
        long newFlags = hints.get_flags() | XUtilConstants.IconPixmapHint | XUtilConstants.IconMaskHint;
        if (getWindow() != 0) {
            newFlags |= XUtilConstants.IconWindowHint;
        }
        hints.set_flags(newFlags);
        hints.set_icon_pixmap(iconPixmap);
        hints.set_icon_mask(iconMask);
        hints.set_icon_window(getWindow());
        XlibWrapper.XSetWMHints(XToolkit.getDisplay(), parent.getShell(), hints.pData);
        log.finest("Set icon window hint");
    } finally {
        XToolkit.awtUnlock();
    }
}
Also used : ImageRepresentation(sun.awt.image.ImageRepresentation) ToolkitImage(sun.awt.image.ToolkitImage)

Example 8 with ToolkitImage

use of sun.awt.image.ToolkitImage in project jdk8u_jdk by JetBrains.

the class WCustomCursor method createNativeCursor.

@Override
protected void createNativeCursor(Image im, int[] pixels, int w, int h, int xHotSpot, int yHotSpot) {
    BufferedImage bimage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics g = bimage.getGraphics();
    try {
        if (im instanceof ToolkitImage) {
            ImageRepresentation ir = ((ToolkitImage) im).getImageRep();
            ir.reconstruct(ImageObserver.ALLBITS);
        }
        g.drawImage(im, 0, 0, w, h, null);
    } finally {
        g.dispose();
    }
    Raster raster = bimage.getRaster();
    DataBuffer buffer = raster.getDataBuffer();
    // REMIND: native code should use ScanStride _AND_ width
    int[] data = ((DataBufferInt) buffer).getData();
    byte[] andMask = new byte[w * h / 8];
    int npixels = pixels.length;
    for (int i = 0; i < npixels; i++) {
        int ibyte = i / 8;
        int omask = 1 << (7 - (i % 8));
        if ((pixels[i] & 0xff000000) == 0) {
            // Transparent bit
            andMask[ibyte] |= omask;
        }
    }
    {
        int ficW = raster.getWidth();
        if (raster instanceof IntegerComponentRaster) {
            ficW = ((IntegerComponentRaster) raster).getScanlineStride();
        }
        createCursorIndirect(((DataBufferInt) bimage.getRaster().getDataBuffer()).getData(), andMask, ficW, raster.getWidth(), raster.getHeight(), xHotSpot, yHotSpot);
    }
}
Also used : ImageRepresentation(sun.awt.image.ImageRepresentation) IntegerComponentRaster(sun.awt.image.IntegerComponentRaster) IntegerComponentRaster(sun.awt.image.IntegerComponentRaster) ToolkitImage(sun.awt.image.ToolkitImage)

Aggregations

ToolkitImage (sun.awt.image.ToolkitImage)8 ImageRepresentation (sun.awt.image.ImageRepresentation)7 AffineTransform (java.awt.geom.AffineTransform)2 BufferedImage (java.awt.image.BufferedImage)2 GradientPaint (java.awt.GradientPaint)1 Graphics2D (java.awt.Graphics2D)1 Image (java.awt.Image)1 LinearGradientPaint (java.awt.LinearGradientPaint)1 Paint (java.awt.Paint)1 RadialGradientPaint (java.awt.RadialGradientPaint)1 TexturePaint (java.awt.TexturePaint)1 ColorSpace (java.awt.color.ColorSpace)1 ColorModel (java.awt.image.ColorModel)1 ComponentColorModel (java.awt.image.ComponentColorModel)1 DataBufferByte (java.awt.image.DataBufferByte)1 DirectColorModel (java.awt.image.DirectColorModel)1 MultiResolutionImage (java.awt.image.MultiResolutionImage)1 RenderedImage (java.awt.image.RenderedImage)1 VolatileImage (java.awt.image.VolatileImage)1 WritableRaster (java.awt.image.WritableRaster)1