Search in sources :

Example 41 with Graphics2D

use of java.awt.Graphics2D in project jdk8u_jdk by JetBrains.

the class RLECompressionTest method getTestImage.

private BufferedImage getTestImage(int type) {
    BufferedImage src = null;
    IndexColorModel icm = getTestColorModel(type);
    src = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_INDEXED, icm);
    Graphics2D g = src.createGraphics();
    g.setColor(Color.white);
    g.fillRect(0, 0, w, h);
    g.dispose();
    return src;
}
Also used : BufferedImage(java.awt.image.BufferedImage) IndexColorModel(java.awt.image.IndexColorModel) Graphics2D(java.awt.Graphics2D)

Example 42 with Graphics2D

use of java.awt.Graphics2D in project jdk8u_jdk by JetBrains.

the class Write3ByteBgrTest method createTestImage.

private static BufferedImage createTestImage(int type, Color c) {
    BufferedImage i = null;
    if (type == BufferedImage.TYPE_CUSTOM) {
        WritableRaster wr = Raster.createBandedRaster(DataBuffer.TYPE_BYTE, width, height, // scanlineStride
        width, // bankIndices[],
        new int[] { 0, 1, 2 }, // bankOffsets[],
        new int[] { 1, 2, 0 }, null);
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        ColorModel cm = new ComponentColorModel(cs, new int[] { 8, 8, 8 }, false, false, ColorModel.OPAQUE, DataBuffer.TYPE_BYTE);
        i = new BufferedImage(cm, wr, false, null);
    } else {
        i = new BufferedImage(width, height, type);
    }
    Graphics2D g = i.createGraphics();
    g.setColor(c);
    g.fillRect(0, 0, width, height);
    g.setColor(Color.white);
    g.drawRect(10, 10, width - 20, height - 20);
    return i;
}
Also used : WritableRaster(java.awt.image.WritableRaster) ColorSpace(java.awt.color.ColorSpace) ComponentColorModel(java.awt.image.ComponentColorModel) ColorModel(java.awt.image.ColorModel) ComponentColorModel(java.awt.image.ComponentColorModel) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 43 with Graphics2D

use of java.awt.Graphics2D in project jdk8u_jdk by JetBrains.

the class WritingColorChangeTest method createTestImage.

private static BufferedImage createTestImage(int type, Color c) {
    BufferedImage i = new BufferedImage(width, height, type);
    Graphics2D g = i.createGraphics();
    g.setColor(c);
    g.fillRect(0, 0, width, height);
    return i;
}
Also used : BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 44 with Graphics2D

use of java.awt.Graphics2D in project jdk8u_jdk by JetBrains.

the class bug8032667 method getImage.

static Image getImage(JComponent component) {
    final BufferedImage image = new BufferedImage(scaledWidth, scaledHeight, BufferedImage.TYPE_INT_ARGB);
    final Graphics g = image.getGraphics();
    ((Graphics2D) g).scale(scale, scale);
    component.paint(g);
    g.dispose();
    return image;
}
Also used : Graphics(java.awt.Graphics) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 45 with Graphics2D

use of java.awt.Graphics2D in project jdk8u_jdk by JetBrains.

the class bug8032667_image_diff method getImage.

static BufferedImage getImage(JComponent component, int scale, int width, int height) {
    final BufferedImage image = new BufferedImage(scale * width, scale * height, BufferedImage.TYPE_INT_ARGB);
    final Graphics g = image.getGraphics();
    ((Graphics2D) g).scale(scale, scale);
    component.paint(g);
    g.dispose();
    return image;
}
Also used : Graphics(java.awt.Graphics) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

Graphics2D (java.awt.Graphics2D)1716 BufferedImage (java.awt.image.BufferedImage)809 Color (java.awt.Color)394 BasicStroke (java.awt.BasicStroke)186 Font (java.awt.Font)161 Point (java.awt.Point)145 AffineTransform (java.awt.geom.AffineTransform)140 Rectangle (java.awt.Rectangle)139 IOException (java.io.IOException)112 Rectangle2D (java.awt.geom.Rectangle2D)100 Dimension (java.awt.Dimension)92 Image (java.awt.Image)91 GradientPaint (java.awt.GradientPaint)90 FontMetrics (java.awt.FontMetrics)87 Paint (java.awt.Paint)82 Graphics (java.awt.Graphics)79 File (java.io.File)65 Point2D (java.awt.geom.Point2D)59 Stroke (java.awt.Stroke)55 ImageIcon (javax.swing.ImageIcon)50