sun.awt.image.ImagingLib Java Examples

The following examples show how to use sun.awt.image.ImagingLib. 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: ConvolveOp.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source {@code Raster} to filter
 * @param dst the destination {@code WritableRaster} for the
 *        filtered {@code src}
 * @return the filtered {@code WritableRaster}
 * @throws NullPointerException if {@code src} is {@code null}
 * @throws ImagingOpException if {@code src} and {@code dst}
 *         do not have the same number of bands
 * @throws ImagingOpException if {@code src} cannot be filtered
 * @throws IllegalArgumentException if {@code src} equals
 *         {@code dst}
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #2
Source File: ConvolveOp.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #3
Source File: ConvolveOp.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #4
Source File: MlibOpsTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #5
Source File: MlibOpsTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #6
Source File: ConvolveOp.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #7
Source File: ConvolveOp.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #8
Source File: MlibOpsTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #9
Source File: ConvolveOp.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #10
Source File: ConvolveOp.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #11
Source File: MlibOpsTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #12
Source File: MlibOpsTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #13
Source File: ConvolveOp.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #14
Source File: ConvolveOp.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #15
Source File: ConvolveOp.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #16
Source File: MlibOpsTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #17
Source File: MlibOpsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #18
Source File: ConvolveOp.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source {@code Raster} to filter
 * @param dst the destination {@code WritableRaster} for the
 *        filtered {@code src}
 * @return the filtered {@code WritableRaster}
 * @throws NullPointerException if {@code src} is {@code null}
 * @throws ImagingOpException if {@code src} and {@code dst}
 *         do not have the same number of bands
 * @throws ImagingOpException if {@code src} cannot be filtered
 * @throws IllegalArgumentException if {@code src} equals
 *         {@code dst}
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #19
Source File: MlibOpsTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #20
Source File: ConvolveOp.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #21
Source File: ConvolveOp.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #22
Source File: MlibOpsTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #23
Source File: MlibOpsTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #24
Source File: ConvolveOp.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #25
Source File: ConvolveOp.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Performs a convolution on Rasters.  Each band of the source Raster
 * will be convolved.
 * The source and destination must have the same number of bands.
 * If the destination Raster is null, a new Raster will be created.
 * The IllegalArgumentException may be thrown if the source is
 * the same as the destination.
 * @param src the source <code>Raster</code> to filter
 * @param dst the destination <code>WritableRaster</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>WritableRaster</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws ImagingOpException if <code>src</code> and <code>dst</code>
 *         do not have the same number of bands
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 */
public final WritableRaster filter (Raster src, WritableRaster dst) {
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    else if (src.getNumBands() != dst.getNumBands()) {
        throw new ImagingOpException("Different number of bands in src "+
                                     " and dst Rasters");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    return dst;
}
 
Example #26
Source File: MlibOpsTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(BufferedImageOp op) {
    BufferedImage src = createSrcImage();
    BufferedImage dst = createImage();
    BufferedImage ret = null;
    try {
        ret = ImagingLib.filter(op, src, dst);
    } catch (Exception e) {
        throw new RuntimeException("Test FAILED.", e);
    }
    if (ret == null) {
        throw new RuntimeException("Test FAILED: null output");
    }

    System.out.println("ret: " + ret);
    System.out.println("Test PASSED for " + op.getClass().getName());
}
 
Example #27
Source File: ConvolveOp.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Performs a convolution on BufferedImages.  Each component of the
 * source image will be convolved (including the alpha component, if
 * present).
 * If the color model in the source image is not the same as that
 * in the destination image, the pixels will be converted
 * in the destination.  If the destination image is null,
 * a BufferedImage will be created with the source ColorModel.
 * The IllegalArgumentException may be thrown if the source is the
 * same as the destination.
 * @param src the source <code>BufferedImage</code> to filter
 * @param dst the destination <code>BufferedImage</code> for the
 *        filtered <code>src</code>
 * @return the filtered <code>BufferedImage</code>
 * @throws NullPointerException if <code>src</code> is <code>null</code>
 * @throws IllegalArgumentException if <code>src</code> equals
 *         <code>dst</code>
 * @throws ImagingOpException if <code>src</code> cannot be filtered
 */
public final BufferedImage filter (BufferedImage src, BufferedImage dst) {
    if (src == null) {
        throw new NullPointerException("src image is null");
    }
    if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }

    boolean needToConvert = false;
    ColorModel srcCM = src.getColorModel();
    ColorModel dstCM;
    BufferedImage origDst = dst;

    // Can't convolve an IndexColorModel.  Need to expand it
    if (srcCM instanceof IndexColorModel) {
        IndexColorModel icm = (IndexColorModel) srcCM;
        src = icm.convertToIntDiscrete(src.getRaster(), false);
        srcCM = src.getColorModel();
    }

    if (dst == null) {
        dst = createCompatibleDestImage(src, null);
        dstCM = srcCM;
        origDst = dst;
    }
    else {
        dstCM = dst.getColorModel();
        if (srcCM.getColorSpace().getType() !=
            dstCM.getColorSpace().getType())
        {
            needToConvert = true;
            dst = createCompatibleDestImage(src, null);
            dstCM = dst.getColorModel();
        }
        else if (dstCM instanceof IndexColorModel) {
            dst = createCompatibleDestImage(src, null);
            dstCM = dst.getColorModel();
        }
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to convolve src image");
    }

    if (needToConvert) {
        ColorConvertOp ccop = new ColorConvertOp(hints);
        ccop.filter(dst, origDst);
    }
    else if (origDst != dst) {
        java.awt.Graphics2D g = origDst.createGraphics();
        try {
            g.drawImage(dst, 0, 0, null);
        } finally {
            g.dispose();
        }
    }

    return origDst;
}
 
Example #28
Source File: AffineTransformOp.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Transforms the source <CODE>Raster</CODE> and stores the results in
 * the destination <CODE>Raster</CODE>.  This operation performs the
 * transform band by band.
 * <p>
 * If the destination <CODE>Raster</CODE> is null, a new
 * <CODE>Raster</CODE> is created.
 * An <CODE>IllegalArgumentException</CODE> may be thrown if the source is
 * the same as the destination or if the number of bands in
 * the source is not equal to the number of bands in the
 * destination.
 * <p>
 * The coordinates of the rectangle returned by
 * <code>getBounds2D(Raster)</code>
 * are not necessarily the same as the coordinates of the
 * <code>WritableRaster</code> returned by this method.  If the
 * upper-left corner coordinates of rectangle are negative then
 * this part of the rectangle is not drawn.  If the coordinates
 * of the rectangle are positive then the filtered image is drawn at
 * that position in the destination <code>Raster</code>.
 * <p>
 * @param src The <CODE>Raster</CODE> to transform.
 * @param dst The <CODE>Raster</CODE> in which to store the results of the
 * transformation.
 *
 * @return The transformed <CODE>Raster</CODE>.
 *
 * @throws ImagingOpException if the raster cannot be transformed
 *         because of a data-processing error that might be
 *         caused by an invalid image format, tile format, or
 *         image-processing operation, or any other unsupported
 *         operation.
 */
public final WritableRaster filter(Raster src, WritableRaster dst) {
    if (src == null) {
        throw new NullPointerException("src image is null");
    }
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    if (src.getNumBands() != dst.getNumBands()) {
        throw new IllegalArgumentException("Number of src bands ("+
                                           src.getNumBands()+
                                           ") does not match number of "+
                                           " dst bands ("+
                                           dst.getNumBands()+")");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to transform src image");
    }
    return dst;
}
 
Example #29
Source File: AffineTransformOp.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Transforms the source <CODE>Raster</CODE> and stores the results in
 * the destination <CODE>Raster</CODE>.  This operation performs the
 * transform band by band.
 * <p>
 * If the destination <CODE>Raster</CODE> is null, a new
 * <CODE>Raster</CODE> is created.
 * An <CODE>IllegalArgumentException</CODE> may be thrown if the source is
 * the same as the destination or if the number of bands in
 * the source is not equal to the number of bands in the
 * destination.
 * <p>
 * The coordinates of the rectangle returned by
 * <code>getBounds2D(Raster)</code>
 * are not necessarily the same as the coordinates of the
 * <code>WritableRaster</code> returned by this method.  If the
 * upper-left corner coordinates of rectangle are negative then
 * this part of the rectangle is not drawn.  If the coordinates
 * of the rectangle are positive then the filtered image is drawn at
 * that position in the destination <code>Raster</code>.
 * <p>
 * @param src The <CODE>Raster</CODE> to transform.
 * @param dst The <CODE>Raster</CODE> in which to store the results of the
 * transformation.
 *
 * @return The transformed <CODE>Raster</CODE>.
 *
 * @throws ImagingOpException if the raster cannot be transformed
 *         because of a data-processing error that might be
 *         caused by an invalid image format, tile format, or
 *         image-processing operation, or any other unsupported
 *         operation.
 */
public final WritableRaster filter(Raster src, WritableRaster dst) {
    if (src == null) {
        throw new NullPointerException("src image is null");
    }
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    if (src == dst) {
        throw new IllegalArgumentException("src image cannot be the "+
                                           "same as the dst image");
    }
    if (src.getNumBands() != dst.getNumBands()) {
        throw new IllegalArgumentException("Number of src bands ("+
                                           src.getNumBands()+
                                           ") does not match number of "+
                                           " dst bands ("+
                                           dst.getNumBands()+")");
    }

    if (ImagingLib.filter(this, src, dst) == null) {
        throw new ImagingOpException ("Unable to transform src image");
    }
    return dst;
}
 
Example #30
Source File: BandCombineOp.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Transforms the <CODE>Raster</CODE> using the matrix specified in the
 * constructor. An <CODE>IllegalArgumentException</CODE> may be thrown if
 * the number of bands in the source or destination is incompatible with
 * the matrix.  See the class comments for more details.
 * <p>
 * If the destination is null, it will be created with a number of bands
 * equalling the number of rows in the matrix. No exception is thrown
 * if the operation causes a data overflow.
 *
 * @param src The <CODE>Raster</CODE> to be filtered.
 * @param dst The <CODE>Raster</CODE> in which to store the results
 * of the filter operation.
 *
 * @return The filtered <CODE>Raster</CODE>.
 *
 * @throws IllegalArgumentException If the number of bands in the
 * source or destination is incompatible with the matrix.
 */
public WritableRaster filter(Raster src, WritableRaster dst) {
    int nBands = src.getNumBands();
    if (ncols != nBands && ncols != (nBands+1)) {
        throw new IllegalArgumentException("Number of columns in the "+
                                           "matrix ("+ncols+
                                           ") must be equal to the number"+
                                           " of bands ([+1]) in src ("+
                                           nBands+").");
    }
    if (dst == null) {
        dst = createCompatibleDestRaster(src);
    }
    else if (nrows != dst.getNumBands()) {
        throw new IllegalArgumentException("Number of rows in the "+
                                           "matrix ("+nrows+
                                           ") must be equal to the number"+
                                           " of bands ([+1]) in dst ("+
                                           nBands+").");
    }

    if (ImagingLib.filter(this, src, dst) != null) {
        return dst;
    }

    int[] pixel = null;
    int[] dstPixel = new int[dst.getNumBands()];
    float accum;
    int sminX = src.getMinX();
    int sY = src.getMinY();
    int dminX = dst.getMinX();
    int dY = dst.getMinY();
    int sX;
    int dX;
    if (ncols == nBands) {
        for (int y=0; y < src.getHeight(); y++, sY++, dY++) {
            dX = dminX;
            sX = sminX;
            for (int x=0; x < src.getWidth(); x++, sX++, dX++) {
                pixel = src.getPixel(sX, sY, pixel);
                for (int r=0; r < nrows; r++) {
                    accum = 0.f;
                    for (int c=0; c < ncols; c++) {
                        accum += matrix[r][c]*pixel[c];
                    }
                    dstPixel[r] = (int) accum;
                }
                dst.setPixel(dX, dY, dstPixel);
            }
        }
    }
    else {
        // Need to add constant
        for (int y=0; y < src.getHeight(); y++, sY++, dY++) {
            dX = dminX;
            sX = sminX;
            for (int x=0; x < src.getWidth(); x++, sX++, dX++) {
                pixel = src.getPixel(sX, sY, pixel);
                for (int r=0; r < nrows; r++) {
                    accum = 0.f;
                    for (int c=0; c < nBands; c++) {
                        accum += matrix[r][c]*pixel[c];
                    }
                    dstPixel[r] = (int) (accum+matrix[r][nBands]);
                }
                dst.setPixel(dX, dY, dstPixel);
            }
        }
    }

    return dst;
}