Java 类java.awt.image.BufferedImageOp 实例源码

项目:openjdk-jdk10    文件:D3DDrawImage.java   
@Override
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 {
            if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#resize(BufferedImage, Method, Mode, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> resize(final BufferedImage src, final Method scalingMethod,
    final Mode resizeMode, final int targetSize, final BufferedImageOp... ops)
    throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.resize(src, scalingMethod, resizeMode, targetSize, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#resize(BufferedImage, int, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> resize(final BufferedImage src, final int targetWidth, final int targetHeight,
    final BufferedImageOp... ops) throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.resize(src, targetWidth, targetHeight, ops);
    }
});
   }
项目:openjdk-jdk10    文件:OGLDrawImage.java   
@Override
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 {
            if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
项目:OpenJSharp    文件:ImageTests.java   
public void runTest(Object ctx, int numReps) {
    ImageOpTests.Context ictx = (ImageOpTests.Context)ctx;
    BufferedImageOp op = ictx.bufImgOp;
    BufferedImage src = ictx.bufSrc;
    BufferedImage dst = ictx.bufDst;
    if (ictx.touchSrc) {
        Graphics gSrc = src.getGraphics();
        do {
            gSrc.fillRect(0, 0, 1, 1);
            op.filter(src, dst);
        } while (--numReps > 0);
    } else {
        do {
            op.filter(src, dst);
        } while (--numReps > 0);
    }
}
项目:OpenJSharp    文件:DrawImage.java   
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);
}
项目:OpenJSharp    文件:SunGraphics2D.java   
public void drawImage(BufferedImage bImg,
                      BufferedImageOp op,
                      int x,
                      int y)  {

    if (bImg == null) {
        return;
    }

    try {
        imagepipe.transformImage(this, bImg, op, x, y);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            imagepipe.transformImage(this, bImg, op, x, y);
        } 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.
        }
    } finally {
        surfaceData.markDirty();
    }
}
项目:OpenJSharp    文件:OGLDrawImage.java   
@Override
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 {
            if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
项目:openjdk-jdk10    文件:SunGraphics2D.java   
public void drawImage(BufferedImage bImg,
                      BufferedImageOp op,
                      int x,
                      int y)  {

    if (bImg == null) {
        return;
    }

    try {
        imagepipe.transformImage(this, bImg, op, x, y);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            imagepipe.transformImage(this, bImg, op, x, y);
        } 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.
        }
    } finally {
        surfaceData.markDirty();
    }
}
项目:OpenJSharp    文件:D3DDrawImage.java   
@Override
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 {
            if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
项目:VTerminal    文件:FlipShader.java   
@Override
public BufferedImage run(final @NonNull BufferedImage image) {
    if (isFlippedHorizontally || isFlippedVertically) {
        final double scaleX = isFlippedHorizontally ? -1 : 1;
        final double scaleY = isFlippedVertically ? -1 : 1;
        final double translateX = isFlippedHorizontally ? -image.getWidth() : 0;
        final double translateY = isFlippedVertically ? -image.getHeight() : 0;

        final AffineTransform tx = AffineTransform.getScaleInstance(scaleX, scaleY);
        tx.translate(translateX, translateY);

        final BufferedImageOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
        return op.filter(image, null);
    }

    return image;
}
项目:ChessBot    文件:ChessBoardUtils.java   
public static BufferedImage blur(BufferedImage src) {
    BufferedImage bufferedImage = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_BYTE_INDEXED);

    int s1 = 7;
    int s2 = 7;
    float level = .1f / 9f;

    float[] filter = new float[s1 * s2];

    for (int i = 0; i < s1 * s2; i++) {
        filter[i] = level;
    }

    Kernel kernel = new Kernel(s1, s2, filter);
    BufferedImageOp op = new ConvolveOp(kernel);
    bufferedImage = op.filter(src, null);

    return bufferedImage;
}
项目:jdk8u-jdk    文件:ImageTests.java   
public void runTest(Object ctx, int numReps) {
    ImageOpTests.Context ictx = (ImageOpTests.Context)ctx;
    BufferedImageOp op = ictx.bufImgOp;
    BufferedImage src = ictx.bufSrc;
    BufferedImage dst = ictx.bufDst;
    if (ictx.touchSrc) {
        Graphics gSrc = src.getGraphics();
        do {
            gSrc.fillRect(0, 0, 1, 1);
            op.filter(src, dst);
        } while (--numReps > 0);
    } else {
        do {
            op.filter(src, dst);
        } while (--numReps > 0);
    }
}
项目:jdk8u-jdk    文件:DrawImage.java   
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);
}
项目:jdk8u-jdk    文件:SunGraphics2D.java   
public void drawImage(BufferedImage bImg,
                      BufferedImageOp op,
                      int x,
                      int y)  {

    if (bImg == null) {
        return;
    }

    try {
        imagepipe.transformImage(this, bImg, op, x, y);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            imagepipe.transformImage(this, bImg, op, x, y);
        } 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.
        }
    } finally {
        surfaceData.markDirty();
    }
}
项目:jdk8u-jdk    文件:OGLDrawImage.java   
@Override
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 {
            if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
项目:jdk8u-jdk    文件:PathGraphics.java   
/**
 * Draws a BufferedImage that is filtered with a BufferedImageOp.
 * The rendering attributes applied include the clip, transform
 * and composite attributes.  This is equivalent to:
 * <pre>
 * img1 = op.filter(img, null);
 * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
 * </pre>
 * @param op The filter to be applied to the image before drawing.
 * @param img The BufferedImage to be drawn.
 *            This method does nothing if <code>img</code> is null.
 * @param x,y The location in user space where the image should be drawn.
 * @see #transform
 * @see #setTransform
 * @see #setComposite
 * @see #clip
 * @see #setClip
 */
public void drawImage(BufferedImage img,
                      BufferedImageOp op,
                      int x,
                      int y) {

    if (img == null) {
        return;
    }

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

    if (op != null) {
        img = op.filter(img, null);
    }
    if (srcWidth <= 0 || srcHeight <= 0) {
        return;
    } else {
        AffineTransform xform = new AffineTransform(1f,0f,0f,1f,x,y);
        drawImageToPlatform(img, xform, null,
                            0, 0, srcWidth, srcHeight, false);
    }

}
项目:jdk8u-jdk    文件:D3DDrawImage.java   
@Override
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 {
            if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
项目:jdk8u-jdk    文件:MlibOpsTest.java   
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());
}
项目:jdk8u-jdk    文件:SamePackingTypeTest.java   
private static void doTest(BufferedImageOp op, int stype, int dtype) {
    final int size = 100;

    final BufferedImage src = new BufferedImage(size, size, stype);
    Graphics2D g = src.createGraphics();
    g.setColor(Color.red);
    g.fillRect(0, 0, size, size);
    g.dispose();


    final BufferedImage dst = new BufferedImage(size, size, dtype);
    g = dst.createGraphics();
    g.setColor(Color.blue);
    g.fillRect(0, 0, size, size);
    g.dispose();

    op.filter(src, dst);

    final int rgb = dst.getRGB(size - 1, size - 1);
    System.out.printf("dst: 0x%X ", rgb);

    if (rgb != 0xFFFF0000) {
        throw new RuntimeException(String.format("Wrong color in dst: 0x%X", rgb));
    }
}
项目:openjdk-jdk10    文件:ImageTests.java   
public void runTest(Object ctx, int numReps) {
    ImageOpTests.Context ictx = (ImageOpTests.Context)ctx;
    BufferedImageOp op = ictx.bufImgOp;
    BufferedImage src = ictx.bufSrc;
    BufferedImage dst = ictx.bufDst;
    if (ictx.touchSrc) {
        Graphics gSrc = src.getGraphics();
        do {
            gSrc.fillRect(0, 0, 1, 1);
            op.filter(src, dst);
        } while (--numReps > 0);
    } else {
        do {
            op.filter(src, dst);
        } while (--numReps > 0);
    }
}
项目:openjdk-jdk10    文件:PathGraphics.java   
/**
 * Draws a BufferedImage that is filtered with a BufferedImageOp.
 * The rendering attributes applied include the clip, transform
 * and composite attributes.  This is equivalent to:
 * <pre>
 * img1 = op.filter(img, null);
 * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
 * </pre>
 * @param op The filter to be applied to the image before drawing.
 * @param img The BufferedImage to be drawn.
 *            This method does nothing if {@code img} is null.
 * @param x,y The location in user space where the image should be drawn.
 * @see #transform
 * @see #setTransform
 * @see #setComposite
 * @see #clip
 * @see #setClip
 */
public void drawImage(BufferedImage img,
                      BufferedImageOp op,
                      int x,
                      int y) {

    if (img == null) {
        return;
    }

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

    if (op != null) {
        img = op.filter(img, null);
    }
    if (srcWidth <= 0 || srcHeight <= 0) {
        return;
    } else {
        AffineTransform xform = new AffineTransform(1f,0f,0f,1f,x,y);
        drawImageToPlatform(img, xform, null,
                            0, 0, srcWidth, srcHeight, false);
    }

}
项目:openjdk-jdk10    文件:MlibOpsTest.java   
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());
}
项目:oscm    文件:ImageProducer.java   
/**
 * @param bimage
 */
private static BufferedImage blurImage(final BufferedImage bimage) {
    float[] fs = new float[] { 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f,
            1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f };
    final Kernel kernel = new Kernel(3, 3, fs);
    final BufferedImageOp op = new ConvolveOp(kernel);
    return op.filter(bimage, null);
}
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#apply(BufferedImage, BufferedImageOp...)
    */
   public static Future<BufferedImage> apply(final BufferedImage src, final BufferedImageOp... ops)
    throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.apply(src, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#crop(BufferedImage, int, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> crop(final BufferedImage src, final int width, final int height,
    final BufferedImageOp... ops) throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.crop(src, width, height, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#crop(BufferedImage, int, int, int, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> crop(final BufferedImage src, final int x, final int y, final int width,
    final int height, final BufferedImageOp... ops) throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.crop(src, x, y, width, height, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#pad(BufferedImage, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> pad(final BufferedImage src, final int padding, final BufferedImageOp... ops)
    throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.pad(src, padding, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#pad(BufferedImage, int, Color, BufferedImageOp...)
    */
   public static Future<BufferedImage> pad(final BufferedImage src, final int padding, final Color color,
    final BufferedImageOp... ops) throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.pad(src, padding, color, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#resize(BufferedImage, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> resize(final BufferedImage src, final int targetSize,
    final BufferedImageOp... ops) throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.resize(src, targetSize, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#resize(BufferedImage, Mode, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> resize(final BufferedImage src, final Mode resizeMode, final int targetSize,
    final BufferedImageOp... ops) throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.resize(src, resizeMode, targetSize, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#resize(BufferedImage, Method, int, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> resize(final BufferedImage src, final Method scalingMethod,
    final int targetWidth, final int targetHeight, final BufferedImageOp... ops) {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.resize(src, scalingMethod, targetWidth, targetHeight, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#resize(BufferedImage, Mode, int, int, BufferedImageOp...)
    */
   public static Future<BufferedImage> resize(final BufferedImage src, final Mode resizeMode, final int targetWidth,
    final int targetHeight, final BufferedImageOp... ops) throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.resize(src, resizeMode, targetWidth, targetHeight, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#resize(BufferedImage, Method, Mode, int, int,
    *      BufferedImageOp...)
    */
   public static Future<BufferedImage> resize(final BufferedImage src, final Method scalingMethod,
    final Mode resizeMode, final int targetWidth, final int targetHeight, final BufferedImageOp... ops)
    throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.resize(src, scalingMethod, resizeMode, targetWidth, targetHeight, ops);
    }
});
   }
项目:lams    文件:AsyncScalr.java   
/**
    * @see Scalr#rotate(BufferedImage, Rotation, BufferedImageOp...)
    */
   public static Future<BufferedImage> rotate(final BufferedImage src, final Rotation rotation,
    final BufferedImageOp... ops) throws IllegalArgumentException, ImagingOpException {
checkService();

return service.submit(new Callable<BufferedImage>() {
    public BufferedImage call() throws Exception {
    return Scalr.rotate(src, rotation, ops);
    }
});
   }
项目:OpenJSharp    文件:BufferedBufImgOps.java   
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
项目:OpenJSharp    文件:BufferedBufImgOps.java   
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) {
    if (biop instanceof ConvolveOp) {
        disableConvolveOp(rq);
    } else if (biop instanceof RescaleOp) {
        disableRescaleOp(rq);
    } else if (biop instanceof LookupOp) {
        disableLookupOp(rq);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}
项目:openjdk-jdk10    文件:MlibOpsTest.java   
private static BufferedImageOp getLookupOp() {
    byte[] inv = new byte[256];
    for (int i = 0; i < 256; i++) {
        inv[i] = (byte)(255 - i);
    }
    ByteLookupTable table = new ByteLookupTable(0, inv);
    return new LookupOp(table, null);
}
项目:openjdk-jdk10    文件:MlibOpsTest.java   
private static BufferedImageOp getConvolveOp() {
    int kw = 3;
    int kh = 3;
    int size = kw * kh;
    float[] kdata = new float[size];
    Arrays.fill(kdata, 1.0f / size);

    Kernel k  = new Kernel(kw, kh, kdata);
    return new ConvolveOp(k);
}
项目:jdk8u-jdk    文件:BufferedBufImgOps.java   
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData,
                                  BufferedImage srcImg,
                                  BufferedImageOp biop)
{
    if (biop instanceof ConvolveOp) {
        enableConvolveOp(rq, srcData, (ConvolveOp)biop);
    } else if (biop instanceof RescaleOp) {
        enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop);
    } else if (biop instanceof LookupOp) {
        enableLookupOp(rq, srcData, srcImg, (LookupOp)biop);
    } else {
        throw new InternalError("Unknown BufferedImageOp");
    }
}