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

下面列出了怎么用java.awt.image.BufferedImageOp的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk8u   文件: 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);
    }

}
 
源代码2 项目: openjdk-jdk9   文件: 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);
}
 
源代码3 项目: hottub   文件: 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();
    }
}
 
源代码4 项目: 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);
    }
}
 
源代码5 项目: jdk8u-dev-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());
}
 
源代码6 项目: jdk8u-dev-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);
}
 
源代码7 项目: jdk8u60   文件: 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());
}
 
源代码8 项目: consulo   文件: ImageLoader.java
@Nonnull
public static Image scaleImage(Image image, double scale) {
  if (scale == 1.0) return image;

  if (image instanceof JBHiDPIScaledImage) {
    return ((JBHiDPIScaledImage)image).scale(scale);
  }
  int w = image.getWidth(null);
  int h = image.getHeight(null);
  if (w <= 0 || h <= 0) {
    return image;
  }
  int width = (int)Math.round(scale * w);
  int height = (int)Math.round(scale * h);
  // Using "QUALITY" instead of "ULTRA_QUALITY" results in images that are less blurry
  // because ultra quality performs a few more passes when scaling, which introduces blurriness
  // when the scaling factor is relatively small (i.e. <= 3.0f) -- which is the case here.
  return Scalr.resize(ImageUtil.toBufferedImage(image), Scalr.Method.QUALITY, Scalr.Mode.FIT_EXACT, width, height, (BufferedImageOp[])null);
}
 
源代码9 项目: openjdk-8   文件: 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);
    }

}
 
源代码10 项目: openjdk-8   文件: 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);
    }
}
 
源代码11 项目: TencentKona-8   文件: 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);
}
 
源代码12 项目: openjdk-8-source   文件: 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());
}
 
源代码13 项目: 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);
    }
}
 
源代码14 项目: jdk8u60   文件: 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);
}
 
源代码15 项目: jdk8u60   文件: 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);
}
 
源代码16 项目: hottub   文件: SamePackingTypeTest.java
public static void main(String[] args) {
    BufferedImageOp op = createTestOp();

    try {
        System.out.print("Integer-based images... ");
        doTest(op, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE);
        System.out.println("done.");

        System.out.print("Byte-based images... ");
        doTest(op, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE);
        System.out.println("done");
    } catch (ImagingOpException e) {
        throw new RuntimeException("Test FAILED", e);
    }
}
 
源代码17 项目: icafe   文件: 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);
		}
	});
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: SamePackingTypeTest.java
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);
}
 
源代码19 项目: RemoteSupportTool   文件: 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);
        }
    });
}
 
源代码20 项目: Pixelitor   文件: Posterize.java
@Override
public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
    int numRedLevels = redLevels.getValue();
    int numGreenLevels = greenLevels.getValue();
    int numBlueLevels = blueLevels.getValue();
    var rgbLookup = new RGBLookup();
    rgbLookup.initFromPosterize(numRedLevels, numGreenLevels, numBlueLevels);

    BufferedImageOp filterOp = new FastLookupOp((ShortLookupTable) rgbLookup.getLookupOp());
    filterOp.filter(src, dest);

    return dest;
}
 
源代码21 项目: java-disassembler   文件: 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);
        }
    });
}
 
源代码22 项目: java-disassembler   文件: 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);
        }
    });
}
 
源代码23 项目: Pixelitor   文件: TestFilterPerformance.java
private static BufferedImageOp getFilter() {
    var f = new KaleidoscopeFilter("Kaleidoscope Test");
    f.setZoom(1.0f);

    f.setProgressTracker(ProgressTracker.NULL_TRACKER);
    return f;
}
 
源代码24 项目: openjdk-8   文件: 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");
    }
}
 
源代码25 项目: dragonwell8_jdk   文件: 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);
}
 
源代码26 项目: 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);
    }
});
   }
 
源代码27 项目: 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);
    }
});
   }
 
源代码28 项目: icafe   文件: 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);
		}
	});
}
 
源代码29 项目: openjdk-jdk9   文件: MlibOpsTest.java
public static void main(String[] args) {
    System.out.println("AffineTransformOp:");
    BufferedImageOp op = getAffineTransformOp();
    doTest(op);

    System.out.println("ConvolveOp:");
    op = getConvolveOp();
    doTest(op);

    System.out.println("LookupOp:");
    op = getLookupOp();
    doTest(op);
}
 
源代码30 项目: gcs   文件: PdfGraphics2D.java
/**
 * @see Graphics2D#drawImage(BufferedImage, BufferedImageOp, int, int)
 */
@Override
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {
	BufferedImage result = img;
	if (op != null) {
		result = op.createCompatibleDestImage(img, img.getColorModel());
		result = op.filter(img, result);
	}
	drawImage(result, x, y, null);
}
 
 类所在包
 同包方法