Search in sources :

Example 6 with AffineTransformOp

use of java.awt.image.AffineTransformOp in project jdk8u_jdk by JetBrains.

the class DrawImage method transformImage.

public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) {
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType());
            return;
        } else {
            img = op.filter(img, null);
        }
    }
    copyImage(sg, img, x, y, null);
}
Also used : AffineTransformOp(java.awt.image.AffineTransformOp)

Example 7 with AffineTransformOp

use of java.awt.image.AffineTransformOp in project jdk8u_jdk by JetBrains.

the class ImagingLib method filter.

public static WritableRaster filter(RasterOp op, Raster src, WritableRaster dst) {
    if (useLib == false) {
        return null;
    }
    // Create the destination tile
    if (dst == null) {
        dst = op.createCompatibleDestRaster(src);
    }
    WritableRaster retRaster = null;
    switch(getNativeOpIndex(op.getClass())) {
        case LOOKUP_OP:
            // REMIND: Fix this!
            LookupTable table = ((LookupOp) op).getTable();
            if (table.getOffset() != 0) {
                // Right now the native code doesn't support offsets
                return null;
            }
            if (table instanceof ByteLookupTable) {
                ByteLookupTable bt = (ByteLookupTable) table;
                if (lookupByteRaster(src, dst, bt.getTable()) > 0) {
                    retRaster = dst;
                }
            }
            break;
        case AFFINE_OP:
            AffineTransformOp bOp = (AffineTransformOp) op;
            double[] matrix = new double[6];
            bOp.getTransform().getMatrix(matrix);
            if (transformRaster(src, dst, matrix, bOp.getInterpolationType()) > 0) {
                retRaster = dst;
            }
            break;
        case CONVOLVE_OP:
            ConvolveOp cOp = (ConvolveOp) op;
            if (convolveRaster(src, dst, cOp.getKernel(), cOp.getEdgeCondition()) > 0) {
                retRaster = dst;
            }
            break;
        default:
            break;
    }
    if (retRaster != null) {
        SunWritableRaster.markDirty(retRaster);
    }
    return retRaster;
}
Also used : WritableRaster(java.awt.image.WritableRaster) ByteLookupTable(java.awt.image.ByteLookupTable) LookupTable(java.awt.image.LookupTable) ConvolveOp(java.awt.image.ConvolveOp) LookupOp(java.awt.image.LookupOp) ByteLookupTable(java.awt.image.ByteLookupTable) AffineTransformOp(java.awt.image.AffineTransformOp)

Example 8 with AffineTransformOp

use of java.awt.image.AffineTransformOp in project Lucee by lucee.

the class Image method threeBBger.

public void threeBBger() throws ExpressionException {
    BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_3BYTE_BGR);
    Graphics2D graphics = img.createGraphics();
    graphics.drawImage(image(), new AffineTransformOp(AffineTransform.getTranslateInstance(0.0, 0.0), 1), 0, 0);
    graphics.dispose();
    image(img);
}
Also used : BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) AffineTransformOp(java.awt.image.AffineTransformOp)

Example 9 with AffineTransformOp

use of java.awt.image.AffineTransformOp in project Lucee by lucee.

the class Image method grayscale.

public void grayscale() throws ExpressionException {
    BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_BYTE_GRAY);
    Graphics2D graphics = img.createGraphics();
    graphics.drawImage(image(), new AffineTransformOp(AffineTransform.getTranslateInstance(0.0, 0.0), 1), 0, 0);
    graphics.dispose();
    image(img);
}
Also used : BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) AffineTransformOp(java.awt.image.AffineTransformOp)

Example 10 with AffineTransformOp

use of java.awt.image.AffineTransformOp in project Lucee by lucee.

the class Image method paste.

public void paste(Image topImage, int x, int y) throws ExpressionException {
    RenderingHints interp = new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    BorderExtender extender = BorderExtender.createInstance(1);
    Graphics2D g = getGraphics();
    g.addRenderingHints(new RenderingHints(JAI.KEY_BORDER_EXTENDER, extender));
    g.drawImage(topImage.image(), (new AffineTransformOp(AffineTransform.getTranslateInstance(x, y), interp)), 0, 0);
}
Also used : BorderExtender(javax.media.jai.BorderExtender) RenderingHints(java.awt.RenderingHints) Graphics2D(java.awt.Graphics2D) AffineTransformOp(java.awt.image.AffineTransformOp)

Aggregations

AffineTransformOp (java.awt.image.AffineTransformOp)48 AffineTransform (java.awt.geom.AffineTransform)31 BufferedImage (java.awt.image.BufferedImage)29 Graphics2D (java.awt.Graphics2D)20 IOException (java.io.IOException)4 Rectangle2D (java.awt.geom.Rectangle2D)3 WritableRaster (java.awt.image.WritableRaster)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Color (java.awt.Color)2 GradientPaint (java.awt.GradientPaint)2 Image (java.awt.Image)2 RenderingHints (java.awt.RenderingHints)2 ByteLookupTable (java.awt.image.ByteLookupTable)2 ConvolveOp (java.awt.image.ConvolveOp)2 LookupOp (java.awt.image.LookupOp)2 LookupTable (java.awt.image.LookupTable)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 ImageException (cbit.image.ImageException)1 GeometryException (cbit.vcell.geometry.GeometryException)1