Search in sources :

Example 1 with ConvolveOp

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

the class EdgeNoOpCrash method createConvolveOp.

private static ConvolveOp createConvolveOp(int edgeHint) {
    final int kw = 3;
    final int kh = 3;
    float[] kdata = new float[kw * kh];
    float v = 1f / kdata.length;
    Arrays.fill(kdata, v);
    Kernel k = new Kernel(kw, kh, kdata);
    ConvolveOp op = new ConvolveOp(k, edgeHint, null);
    return op;
}
Also used : ConvolveOp(java.awt.image.ConvolveOp) Kernel(java.awt.image.Kernel) Point(java.awt.Point)

Example 2 with ConvolveOp

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

the class SamePackingTypeTest method createTestOp.

private static BufferedImageOp createTestOp() {
    final int size = 1;
    final float v = 1f / (size * size);
    final float[] k_data = new float[size * size];
    Arrays.fill(k_data, v);
    Kernel k = new Kernel(size, size, k_data);
    return new ConvolveOp(k);
}
Also used : ConvolveOp(java.awt.image.ConvolveOp) Kernel(java.awt.image.Kernel)

Example 3 with ConvolveOp

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

the class D3DBufImgOps method renderImageWithOp.

/**
     * This method is called from D3DDrawImage.transformImage() only.  It
     * validates the provided BufferedImageOp to determine whether the op
     * is one that can be accelerated by the D3D pipeline.  If the operation
     * cannot be completed for any reason, this method returns false;
     * otherwise, the given BufferedImage is rendered to the destination
     * using the provided BufferedImageOp and this method returns true.
     */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img, BufferedImageOp biop, int x, int y) {
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp) biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp) biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp) biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }
    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof D3DSurfaceData) || (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) || (sg.compositeState > SunGraphics2D.COMP_ALPHA)) {
        return false;
    }
    SurfaceData srcData = dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
    if (!(srcData instanceof D3DSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData = dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
        if (!(srcData instanceof D3DSurfaceData)) {
            return false;
        }
    }
    // Verify that the source surface is actually a texture and that
    // shaders are supported
    D3DSurfaceData d3dSrc = (D3DSurfaceData) srcData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice) d3dSrc.getDeviceConfiguration().getDevice();
    if (d3dSrc.getType() != D3DSurfaceData.TEXTURE || !gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    int sw = img.getWidth();
    int sh = img.getHeight();
    D3DBlitLoops.IsoBlit(srcData, dstData, img, biop, sg.composite, sg.getCompClip(), sg.transform, sg.interpolationType, 0, 0, sw, sh, x, y, x + sw, y + sh, true);
    return true;
}
Also used : RescaleOp(java.awt.image.RescaleOp) SurfaceData(sun.java2d.SurfaceData) ConvolveOp(java.awt.image.ConvolveOp) LookupOp(java.awt.image.LookupOp)

Example 4 with ConvolveOp

use of java.awt.image.ConvolveOp 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 5 with ConvolveOp

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

the class OGLBufImgOps method renderImageWithOp.

/**
     * This method is called from OGLDrawImage.transformImage() only.  It
     * validates the provided BufferedImageOp to determine whether the op
     * is one that can be accelerated by the OGL pipeline.  If the operation
     * cannot be completed for any reason, this method returns false;
     * otherwise, the given BufferedImage is rendered to the destination
     * using the provided BufferedImageOp and this method returns true.
     */
static boolean renderImageWithOp(SunGraphics2D sg, BufferedImage img, BufferedImageOp biop, int x, int y) {
    // is supported, and that its properties are acceleratable)
    if (biop instanceof ConvolveOp) {
        if (!isConvolveOpValid((ConvolveOp) biop)) {
            return false;
        }
    } else if (biop instanceof RescaleOp) {
        if (!isRescaleOpValid((RescaleOp) biop, img)) {
            return false;
        }
    } else if (biop instanceof LookupOp) {
        if (!isLookupOpValid((LookupOp) biop, img)) {
            return false;
        }
    } else {
        // No acceleration for other BufferedImageOps (yet)
        return false;
    }
    SurfaceData dstData = sg.surfaceData;
    if (!(dstData instanceof OGLSurfaceData) || (sg.interpolationType == AffineTransformOp.TYPE_BICUBIC) || (sg.compositeState > SunGraphics2D.COMP_ALPHA)) {
        return false;
    }
    SurfaceData srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
    if (!(srcData instanceof OGLSurfaceData)) {
        // REMIND: this hack tries to ensure that we have a cached texture
        srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT, CompositeType.SrcOver, null);
        if (!(srcData instanceof OGLSurfaceData)) {
            return false;
        }
    }
    // Verify that the source surface is actually a texture and
    // that the operation is supported
    OGLSurfaceData oglSrc = (OGLSurfaceData) srcData;
    OGLGraphicsConfig gc = oglSrc.getOGLGraphicsConfig();
    if (oglSrc.getType() != OGLSurfaceData.TEXTURE || !gc.isCapPresent(CAPS_EXT_BIOP_SHADER)) {
        return false;
    }
    int sw = img.getWidth();
    int sh = img.getHeight();
    OGLBlitLoops.IsoBlit(srcData, dstData, img, biop, sg.composite, sg.getCompClip(), sg.transform, sg.interpolationType, 0, 0, sw, sh, x, y, x + sw, y + sh, true);
    return true;
}
Also used : RescaleOp(java.awt.image.RescaleOp) SurfaceData(sun.java2d.SurfaceData) ConvolveOp(java.awt.image.ConvolveOp) LookupOp(java.awt.image.LookupOp)

Aggregations

ConvolveOp (java.awt.image.ConvolveOp)26 Kernel (java.awt.image.Kernel)21 BufferedImage (java.awt.image.BufferedImage)15 Color (java.awt.Color)4 GradientPaint (java.awt.GradientPaint)4 Graphics2D (java.awt.Graphics2D)4 LookupOp (java.awt.image.LookupOp)4 Font (java.awt.Font)3 FontMetrics (java.awt.FontMetrics)3 Rectangle2D (java.awt.geom.Rectangle2D)3 RoundRectangle2D (java.awt.geom.RoundRectangle2D)3 Point (java.awt.Point)2 AffineTransformOp (java.awt.image.AffineTransformOp)2 ByteLookupTable (java.awt.image.ByteLookupTable)2 LookupTable (java.awt.image.LookupTable)2 RescaleOp (java.awt.image.RescaleOp)2 WritableRaster (java.awt.image.WritableRaster)2 SurfaceData (sun.java2d.SurfaceData)2 JPEGEncodeParam (com.sun.image.codec.jpeg.JPEGEncodeParam)1 JPEGImageEncoder (com.sun.image.codec.jpeg.JPEGImageEncoder)1