JHFilter implements BufferedImageOp { @Override public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) { if (dstCM == null) { dstCM = src.getColorModel(); } return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null); }  @Override BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM); @Override Rectangle2D getBounds2D(BufferedImage src); @Override Point2D getPoint2D(Point2D srcPt, Point2D dstPt); @Override RenderingHints getRenderingHints(); int[] getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels); void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels);  }
@Test public void test_createCompatibleDestImage() { final TestFilter filter = new TestFilter(); final BufferedImage image1 = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED); final BufferedImage image2 = filter.createCompatibleDestImage(image1, null); Assertions .assertThat(image2.getType()) .isEqualTo(image1.getType()); }