@Test
public void testImageCopy() throws IOException {

  BufferedImage original = getSampleImage();
  ImagePoolImpl.ImageImpl image = (ImagePoolImpl.ImageImpl)myPool.copyOf(original);
  assertNotEquals(original, image.myBuffer);
  BufferedImage copy = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB);
  image.drawImageTo(copy);
  ImageDiffUtil.assertImageSimilar("pooledimage", original, copy, 0.0);
  copy = image.getCopy();
  assertNotEquals(copy, image.myBuffer);
  ImageDiffUtil.assertImageSimilar("pooledimage", original, copy, 0.0);
  copy = image.getCopy(0, 0, 25, 50);
  assertNotEquals(copy, image.myBuffer);
  assertEquals(25, copy.getWidth());
  assertEquals(50, copy.getHeight());
  ImageDiffUtil.assertImageSimilar("pooledimage", original.getSubimage(0, 0, 25, 50), copy, 0.0);
  copy = image.getCopy(10, 10, 25, 25);
  assertNotEquals(copy, image.myBuffer);
  assertEquals(25, copy.getWidth());
  assertEquals(25, copy.getHeight());
  ImageDiffUtil.assertImageSimilar("pooledimage", original.getSubimage(10, 10, 25, 25), copy, 0.0);
  try {
    //noinspection UnusedAssignment
    copy = image.getCopy(0, 0, 25, 150);
    fail("IndexOutOfBoundsException expected for height out of bounds");
  }
  catch (IndexOutOfBoundsException ignored) {
  }
}