java.awt.Image Java Examples

The following examples show how to use java.awt.Image. 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: LUTCompareTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    Image img = createTestImage();

    Toolkit tk = Toolkit.getDefaultToolkit();

    LUTCompareTest o = new LUTCompareTest(img);

    tk.prepareImage(img, -1, -1, o);

    while(!o.isImageReady()) {
        synchronized(lock) {
            try {
                lock.wait(200);
            } catch (InterruptedException e) {
            }
        }
    }

    checkResults(img);
}
 
Example #2
Source File: EndpointArgumentsBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an AttachmentBuilder based on the parameter type
 *
 * @param param
 *      runtime Parameter that abstracts the annotated java parameter
 * @param setter
 *      specifies how the obtained value is set into the argument. Takes
 *      care of Holder arguments.
 */
public static EndpointArgumentsBuilder createAttachmentBuilder(ParameterImpl param, EndpointValueSetter setter) {
    Class type = (Class)param.getTypeInfo().type;
    if (DataHandler.class.isAssignableFrom(type)) {
        return new DataHandlerBuilder(param, setter);
    } else if (byte[].class==type) {
        return new ByteArrayBuilder(param, setter);
    } else if(Source.class.isAssignableFrom(type)) {
        return new SourceBuilder(param, setter);
    } else if(Image.class.isAssignableFrom(type)) {
        return new ImageBuilder(param, setter);
    } else if(InputStream.class==type) {
        return new InputStreamBuilder(param, setter);
    } else if(isXMLMimeType(param.getBinding().getMimeType())) {
        return new JAXBBuilder(param, setter);
    } else if(String.class.isAssignableFrom(type)) {
        return new StringBuilder(param, setter);
    } else {
        throw new UnsupportedOperationException("Unknown Type="+type+" Attachment is not mapped.");
    }
}
 
Example #3
Source File: LUTCompareTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static Image createTestImage() throws IOException  {
    BufferedImage frame1 = createFrame(new int[] { 0xffff0000, 0xffff0000 });
    BufferedImage frame2 = createFrame(new int[] { 0xff0000ff, 0xffff0000 });

    ImageWriter writer = ImageIO.getImageWritersByFormatName("GIF").next();
    ImageOutputStream ios = ImageIO.createImageOutputStream(new File("lut_test.gif"));
    ImageWriteParam param = writer.getDefaultWriteParam();
    writer.setOutput(ios);
    writer.prepareWriteSequence(null);
    writer.writeToSequence(new IIOImage(frame1, null, null), param);
    writer.writeToSequence(new IIOImage(frame2, null, null), param);
    writer.endWriteSequence();
    writer.reset();
    writer.dispose();

    ios.flush();
    ios.close();

    return Toolkit.getDefaultToolkit().createImage("lut_test.gif");
}
 
Example #4
Source File: PathGraphics.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public boolean drawImage(Image img, int x, int y,
                         Color bgcolor,
                         ImageObserver observer) {

    if (img == null) {
        return true;
    }

    boolean result;
    int srcWidth = img.getWidth(null);
    int srcHeight = img.getHeight(null);

    if (srcWidth < 0 || srcHeight < 0) {
        result = false;
    } else {
        result = drawImage(img, x, y, srcWidth, srcHeight, bgcolor, observer);
    }

    return result;
}
 
Example #5
Source File: LUTCompareTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    Image img = createTestImage();

    Toolkit tk = Toolkit.getDefaultToolkit();

    LUTCompareTest o = new LUTCompareTest(img);

    tk.prepareImage(img, -1, -1, o);

    while(!o.isImageReady()) {
        synchronized(lock) {
            try {
                lock.wait(200);
            } catch (InterruptedException e) {
            }
        }
    }

    checkResults(img);
}
 
Example #6
Source File: WTrayIconPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();

    BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
                                               BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
                         (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
 
Example #7
Source File: ResourceHolderSwing.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Load line clear effect images.
 */
public static void loadLineClearEffectImages() {
	String skindir = NullpoMinoSwing.propConfig.getProperty("custom.skin.directory", "res");

	if(imgBreak == null) {
		imgBreak = new Image[BLOCK_BREAK_MAX][BLOCK_BREAK_SEGMENTS];

		for(int i = 0; i < BLOCK_BREAK_MAX; i++) {
			for(int j = 0; j < BLOCK_BREAK_SEGMENTS; j++) {
				imgBreak[i][j] = loadImage(getURL(skindir + "/graphics/break" + i + "_" + j + ".png"));
			}
		}
	}
	if(imgPErase == null) {
		imgPErase = new Image[PERASE_MAX];

		for(int i = 0; i < imgPErase.length; i++) {
			imgPErase[i] = loadImage(getURL(skindir + "/graphics/perase" + i + ".png"));
		}
	}
}
 
Example #8
Source File: TranslucentWindowPainter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Updates the window associated with the painter.
 *
 * @param repaint indicates if the window should be completely repainted
 * to the back buffer using {@link java.awt.Window#paintAll} before update.
 */
public void updateWindow(boolean repaint) {
    boolean done = false;
    Image bb = getBackBuffer(repaint);
    while (!done) {
        if (repaint) {
            Graphics2D g = (Graphics2D)bb.getGraphics();
            try {
                window.paintAll(g);
            } finally {
                g.dispose();
            }
        }

        done = update(bb);
        if (!done) {
            repaint = true;
            bb = getBackBuffer(true);
        }
    }
}
 
Example #9
Source File: left_TilesetManager_1.22.java    From gumtree-spoon-ast-diff with Apache License 2.0 6 votes vote down vote up
public void loadPreviewImage(Entity entity, Image camo, int tint, BufferedPanel bp) {
Image base = mechTileset.imageFor(entity, comp);
EntityImage entityImage = new EntityImage(base, tint, camo, bp);
Image preview = entityImage.loadPreviewImage();

BackGroundDrawer bgdPreview = new BackGroundDrawer(preview);
bp.removeBgDrawers();
bp.addBgDrawer(bgdPreview);

MediaTracker tracker = new MediaTracker(comp);
tracker.addImage(preview, 0);
try {
	tracker.waitForID(0);
} catch (InterruptedException e) {
	;
}

  }
 
Example #10
Source File: ImageUtil.java    From util with Apache License 2.0 6 votes vote down vote up
/**
 * 给图片添加文字水印
 * @param pressText 水印文字
 * @param srcImageFile 源图像地址
 * @param destImageFile 目标图像地址
 * @param fontName 字体名称
 * @param fontStyle 字体样式
 * @param color 字体颜色
 * @param fontSize 字体大小
 * @param x 修正值
 * @param y 修正值
 * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
 */
public final static void pressText2(String pressText, String srcImageFile,String destImageFile,
        String fontName, int fontStyle, Color color, int fontSize, int x,
        int y, float alpha) {
    try {
        File img = new File(srcImageFile);
        Image src = ImageIO.read(img);
        int width = src.getWidth(null);
        int height = src.getHeight(null);
        BufferedImage image = new BufferedImage(width, height,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g = image.createGraphics();
        g.drawImage(src, 0, 0, width, height, null);
        g.setColor(color);
        g.setFont(new Font(fontName, fontStyle, fontSize));
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
                alpha));
        // 在指定坐标绘制水印文字
        g.drawString(pressText, (width - (getLength(pressText) * fontSize))
                / 2 + x, (height - fontSize) / 2 + y);
        g.dispose();
        ImageIO.write((BufferedImage) image, "JPEG", new File(destImageFile));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #11
Source File: DOMNodeAnnotator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void annotate(Node node, Image badge) {
    int nodeId = node.getNodeId();
    if (badge == null) {
        badges.remove(nodeId);
    } else {
        badges.put(node.getNodeId(), badge);
    }
    Page page = PageInspector.getDefault().getPage();
    if (page instanceof WebKitPageModel) {
        WebKitPageModel pageModel = (WebKitPageModel)page;
        DOMNode domNode = pageModel.getNode(node.getNodeId());
        if (domNode != null) {
            domNode.updateIcon();
        }
    }
}
 
Example #12
Source File: LUTCompareTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    Image img = createTestImage();

    Toolkit tk = Toolkit.getDefaultToolkit();

    LUTCompareTest o = new LUTCompareTest(img);

    tk.prepareImage(img, -1, -1, o);

    while(!o.isImageReady()) {
        synchronized(lock) {
            try {
                lock.wait(200);
            } catch (InterruptedException e) {
            }
        }
    }

    checkResults(img);
}
 
Example #13
Source File: TranslucentWindowPainter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Updates the window associated with the painter.
 *
 * @param repaint indicates if the window should be completely repainted
 * to the back buffer using {@link java.awt.Window#paintAll} before update.
 */
public void updateWindow(boolean repaint) {
    boolean done = false;
    Image bb = getBackBuffer(repaint);
    while (!done) {
        if (repaint) {
            Graphics2D g = (Graphics2D)bb.getGraphics();
            try {
                window.paintAll(g);
            } finally {
                g.dispose();
            }
        }

        done = update(bb);
        if (!done) {
            repaint = true;
            bb = getBackBuffer(true);
        }
    }
}
 
Example #14
Source File: SunGraphics2D.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private boolean drawHiDPIImage(Image img, int dx1, int dy1, int dx2,
                               int dy2, int sx1, int sy1, int sx2, int sy2,
                               Color bgcolor, ImageObserver observer) {
    final int scale = SurfaceManager.getImageScale(img);
    sx1 = Region.clipScale(sx1, scale);
    sx2 = Region.clipScale(sx2, scale);
    sy1 = Region.clipScale(sy1, scale);
    sy2 = Region.clipScale(sy2, scale);
    try {
        return imagepipe.scaleImage(this, img, dx1, dy1, dx2, dy2, sx1, sy1,
                                    sx2, sy2, bgcolor, observer);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            return imagepipe.scaleImage(this, img, dx1, dy1, dx2, dy2, sx1,
                                        sy1, sx2, sy2, bgcolor, observer);
        } catch (InvalidPipeException e2) {
            // Still catching the exception; we are not yet ready to
            // validate the surfaceData correctly.  Fail for now and
            // try again next time around.
            return false;
        }
    } finally {
        surfaceData.markDirty();
    }
}
 
Example #15
Source File: GameFrame.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
void setIcon() {
  String iconName = "cloud32x32.gif";
  if (Util.isWindows()) {
    iconName = "cloud16x16.gif";
  }
  String strURL = "/data/" + iconName;
  try {
    MediaTracker tracker = new MediaTracker(frame);

    URL url = getClass().getResource(strURL);

    if(url != null) {
      Image image = frame.getToolkit().getImage(url);
      tracker.addImage(image, 0);
      tracker.waitForID(0);

      frame.setIconImage(image);
    } else {
    }
  } catch (Exception e) {
  }
}
 
Example #16
Source File: CGLSurfaceData.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public CGLVSyncOffScreenSurfaceData(CPlatformView pView,
        CGLGraphicsConfig gc, int width, int height, Image image,
        ColorModel cm, int type) {
    super(pView, gc, width, height, image, cm, type);
    flipSurface = CGLSurfaceData.createData(pView, image,
            FLIP_BACKBUFFER);
}
 
Example #17
Source File: JSystemTray.java    From PeerWasp with MIT License 5 votes vote down vote up
private TrayIcon create(Image image) throws IOException {
	TrayIcon trayIcon = new java.awt.TrayIcon(image);
	trayIcon.setImageAutoSize(true);
	trayIcon.setToolTip(tooltip);
	trayIcon.setPopupMenu(createMenu(false));
	return trayIcon;
}
 
Example #18
Source File: StarRater.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Converts an image to a compressed byte array. GZIPs the image to reduce the size. Use compressedByteArrayToImage(byte[] data) to
 * retrieve the original image. The image is not recognizable as image from standard tools.
 *
 * @param image  The image to convert.
 * @return  The byte array.
 * @throws IOException if something goes wrong.
 */
public byte[] imageToCompressedByteArray(Image image) throws IOException {
  // get image size
  int width = image.getWidth(null);
  int height = image.getHeight(null);

  // store image data as raw int values
  try {
    int[] imageSource = new int[width * height];
    PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, imageSource, 0, width);
    pg.grabPixels();

    // zip data
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    GZIPOutputStream zippedStream = new GZIPOutputStream(byteStream);
    ObjectOutputStream objectStream = new ObjectOutputStream(zippedStream);
    objectStream.writeShort(width);
    objectStream.writeShort(height);
    objectStream.writeObject(imageSource);
    objectStream.flush();
    objectStream.close();
    return byteStream.toByteArray();
  }
  catch (Exception e) {
    throw new IOException("Error storing image in object: " + e);
  }
}
 
Example #19
Source File: bug8032667_image_diff.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static BufferedImage getScaledImage(JComponent component) {
    Image image1x = getImage(component, 1, IMAGE_WIDTH, IMAGE_HEIGHT);
    final BufferedImage image2x = new BufferedImage(
            2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT, BufferedImage.TYPE_INT_ARGB);
    final Graphics g = image2x.getGraphics();
    ((Graphics2D) g).scale(2, 2);
    g.drawImage(image1x, 0, 0, null);
    g.dispose();
    return image2x;
}
 
Example #20
Source File: DitherTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculates and returns the image.  Halts the calculation and returns
 * null if the Applet is stopped during the calculation.
 */
private Image calculateImage() {
    Thread me = Thread.currentThread();

    int width = canvas.getSize().width;
    int height = canvas.getSize().height;
    int xvals[] = new int[2];
    int yvals[] = new int[2];
    int xmethod = XControls.getParams(xvals);
    int ymethod = YControls.getParams(yvals);
    int pixels[] = new int[width * height];
    int c[] = new int[4];   //temporarily holds R,G,B,A information
    int index = 0;
    for (int j = 0; j < height; j++) {
        for (int i = 0; i < width; i++) {
            c[0] = c[1] = c[2] = 0;
            c[3] = 255;
            if (xmethod < ymethod) {
                applyMethod(c, xmethod, i, width, xvals);
                applyMethod(c, ymethod, j, height, yvals);
            } else {
                applyMethod(c, ymethod, j, height, yvals);
                applyMethod(c, xmethod, i, width, xvals);
            }
            pixels[index++] = ((c[3] << 24) | (c[0] << 16) | (c[1] << 8)
                    | c[2]);
        }

        // Poll once per row to see if we've been told to stop.
        if (runner != me) {
            return null;
        }
    }
    return createImage(new MemoryImageSource(width, height,
            ColorModel.getRGBdefault(), pixels, 0, width));
}
 
Example #21
Source File: WDataTransferer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translates either a byte array or an input stream which contain
 * platform-specific image data in the given format into an Image.
 */
@Override
protected Image platformImageBytesToImage(byte[] bytes, long format)
        throws IOException {
    String mimeType = null;
    if (format == CF_PNG) {
        mimeType = "image/png";
    } else if (format == CF_JFIF) {
        mimeType = "image/jpeg";
    }
    if (mimeType != null) {
        return standardImageBytesToImage(bytes, mimeType);
    }

    int[] imageData = platformImageBytesToImageData(bytes, format);
    if (imageData == null) {
        throw new IOException("data translation failed");
    }

    int len = imageData.length - 2;
    int width = imageData[len];
    int height = imageData[len + 1];

    DataBufferInt buffer = new DataBufferInt(imageData, len);
    WritableRaster raster = Raster.createPackedRaster(buffer, width,
            height, width,
            bandmasks, null);

    return new BufferedImage(directColorModel, raster, false, null);
}
 
Example #22
Source File: DrawBitmaskToSurfaceTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Image createTestImage() {
    byte[] r = new byte[]{(byte)0x00, (byte)0x80, (byte)0xff, (byte)0xff};
    byte[] g = new byte[]{(byte)0x00, (byte)0x80, (byte)0xff, (byte)0x00};
    byte[] b = new byte[]{(byte)0x00, (byte)0x80, (byte)0xff, (byte)0x00};

    IndexColorModel icm = new IndexColorModel(2, 4, r, g, b, 3);

    BufferedImage img = new BufferedImage(100, 100,
                                          BufferedImage.TYPE_BYTE_INDEXED,
                                          icm);
    return img;
}
 
Example #23
Source File: GhidraApplicationInformationDisplayFactory.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Image> doGetWindowIcons() {
	List<Image> list = new ArrayList<>();
	list.add(ResourceManager.loadImage("images/GhidraIcon16.png").getImage());
	list.add(ResourceManager.loadImage("images/GhidraIcon24.png").getImage());
	list.add(ResourceManager.loadImage("images/GhidraIcon32.png").getImage());
	list.add(ResourceManager.loadImage("images/GhidraIcon40.png").getImage());
	list.add(ResourceManager.loadImage("images/GhidraIcon48.png").getImage());
	list.add(ResourceManager.loadImage("images/GhidraIcon64.png").getImage());
	list.add(ResourceManager.loadImage("images/GhidraIcon128.png").getImage());
	list.add(ResourceManager.loadImage("images/GhidraIcon256.png").getImage());
	return list;
}
 
Example #24
Source File: ScaledBitmapIcon.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ScaledBitmapIcon(Image sourceImage, int width, int height) {
    super(width, height);
    Parameters.notNull("sourceImage", sourceImage);
    this.sourceImage = sourceImage;
    /* Like ImageIcon, we block until the image is fully loaded. Just rely on ImageIcon's
    implementation here (it will ll get a MediaTracker, call waitForID etc.). */
    Icon imageIcon = new ImageIcon(sourceImage);
    sourceWidth = imageIcon.getIconWidth();
    sourceHeight = imageIcon.getIconHeight();
}
 
Example #25
Source File: CGLGraphicsConfig.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
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 #26
Source File: SysTray.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private Image createTrayImage() {
    Dimension iconDimension = SystemTray.getSystemTray().getTrayIconSize();
    int iconWidth = iconDimension.width;
    int iconHeight = iconDimension.height;

    if (iconWidth <= 16 && iconHeight <= 16)
        return ImageUtilities.loadImage("org/graalvm/visualvm/modules/systray/resources/icon16.png"); // NOI18N

    if (iconWidth <= 32 && iconHeight <= 32)
        return ImageUtilities.loadImage("org/graalvm/visualvm/modules/systray/resources/icon32.png"); // NOI18N

    return ImageUtilities.loadImage("org/graalvm/visualvm/modules/systray/resources/icon48.png"); // NOI18N
}
 
Example #27
Source File: Barcode128.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Creates a <CODE>java.awt.Image</CODE>. This image only
 * contains the bars without any text.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();
    String bCode;
    if (codeType == CODE128_RAW) {
        int idx = code.indexOf('\uffff');
        if (idx >= 0)
            bCode = code.substring(0, idx);
        else
            bCode = code;
    }
    else {
        bCode = getRawText(code, codeType == CODE128_UCC);
    }
    int len = bCode.length();
    int fullWidth = (len + 2) * 11 + 2;
    byte bars[] = getBarsCode128Raw(bCode);
    
    boolean print = true;
    int ptr = 0;
    int height = (int)barHeight;
    int pix[] = new int[fullWidth * height];
    for (int k = 0; k < bars.length; ++k) {
        int w = bars[k];
        int c = g;
        if (print)
            c = f;
        print = !print;
        for (int j = 0; j < w; ++j)
            pix[ptr++] = c;
    }
    for (int k = fullWidth; k < pix.length; k += fullWidth) {
        System.arraycopy(pix, 0, pix, k, fullWidth); 
    }
    Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
    
    return img;
}
 
Example #28
Source File: SunGraphics2D.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Draws an image at x,y in nonblocking mode with a solid background
 * color and a callback object.
 */
public boolean drawImage(Image img, int x, int y, Color bg,
                         ImageObserver observer) {

    if (img == null) {
        return true;
    }

    final int imgW = img.getWidth(null);
    final int imgH = img.getHeight(null);
    Boolean hidpiImageDrawn = drawHiDPIImage(img, x, y, x + imgW, y + imgH,
                                             0, 0, imgW, imgH, bg, observer,
                                             null);
    if (hidpiImageDrawn != null) {
        return hidpiImageDrawn;
    }

    try {
        return imagepipe.copyImage(this, img, x, y, bg, observer);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            return imagepipe.copyImage(this, img, x, y, bg, observer);
        } catch (InvalidPipeException e2) {
            // Still catching the exception; we are not yet ready to
            // validate the surfaceData correctly.  Fail for now and
            // try again next time around.
            return false;
        }
    } finally {
        surfaceData.markDirty();
    }
}
 
Example #29
Source File: PeekGraphics.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
synchronized public boolean imageUpdate(Image image, int flags,
                                        int x, int y, int w, int h) {

    boolean dontCallMeAgain = (flags & (HEIGHT | ABORT | ERROR)) != 0;
    badImage = (flags & (ABORT | ERROR)) != 0;

    return dontCallMeAgain;
}
 
Example #30
Source File: D3DDrawImage.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void renderImageXform(SunGraphics2D sg, Image img,
                                AffineTransform tx, int interpType,
                                int sx1, int sy1, int sx2, int sy2,
                                Color bgColor)
{
    // punt to the MediaLib-based transformImage() in the superclass if:
    //     - bicubic interpolation is specified
    //     - a background color is specified and will be used
    //     - an appropriate TransformBlit primitive could not be found
    if (interpType != AffineTransformOp.TYPE_BICUBIC) {
        SurfaceData dstData = sg.surfaceData;
        SurfaceData srcData =
            dstData.getSourceSurfaceData(img,
                                         SunGraphics2D.TRANSFORM_GENERIC,
                                         sg.imageComp,
                                         bgColor);

        if (srcData != null && !isBgOperation(srcData, bgColor)) {
            SurfaceType srcType = srcData.getSurfaceType();
            SurfaceType dstType = dstData.getSurfaceType();
            TransformBlit blit = TransformBlit.getFromCache(srcType,
                                                            sg.imageComp,
                                                            dstType);

            if (blit != null) {
                blit.Transform(srcData, dstData,
                               sg.composite, sg.getCompClip(),
                               tx, interpType,
                               sx1, sy1, 0, 0, sx2-sx1, sy2-sy1);
                return;
            }
        }
    }

    super.renderImageXform(sg, img, tx, interpType,
                           sx1, sy1, sx2, sy2, bgColor);
}