### Question:
ImageUtil { public static BufferedImage resizeCanvas(final BufferedImage image, final int newWidth, final int newHeight) { final BufferedImage dimg = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB); final int centeredX = newWidth / 2 - image.getWidth() / 2; final int centeredY = newHeight / 2 - image.getHeight() / 2; final Graphics2D g2d = dimg.createGraphics(); g2d.drawImage(image, centeredX, centeredY, null); g2d.dispose(); return dimg; }  static BufferedImage bufferedImageFromImage(final Image image); static BufferedImage grayscaleOffset(final BufferedImage image, final int offset); static BufferedImage grayscaleOffset(final BufferedImage image, final float percentage); static BufferedImage alphaOffset(final BufferedImage image, final int offset); static BufferedImage alphaOffset(final BufferedImage image, final float percentage); static BufferedImage grayscaleImage(final BufferedImage image); static BufferedImage resizeImage(final BufferedImage image, final int newWidth, final int newHeight); static BufferedImage resizeCanvas(final BufferedImage image, final int newWidth, final int newHeight); static BufferedImage rotateImage(final BufferedImage image, final double theta); static BufferedImage flipImage(final BufferedImage image, final boolean horizontal, final boolean vertical); static BufferedImage outlineImage(final BufferedImage image, final Color color); static BufferedImage outlineImage(final BufferedImage image, final Color color, final Predicate<Color> fillCondition); static BufferedImage outlineImage(final BufferedImage image, final Color color, final Boolean outlineCorners); static BufferedImage outlineImage(final BufferedImage image, final Color color, final Predicate<Color> fillCondition, final Boolean outlineCorners); static BufferedImage getResourceStreamFromClass(final Class c, final String path); static BufferedImage fillImage(final BufferedImage image, final Color color); static SpritePixels getImageSpritePixels(BufferedImage image, Client client);  }### Answer:
@Test public void resizeCanvas() { assertTrue(bufferedImagesEqual(centeredPixel(BLACK), ImageUtil.resizeCanvas(oneByOne(BLACK), 3, 3))); assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.resizeCanvas(oneByOne(BLACK), 1, 1))); assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.resizeCanvas(centeredPixel(BLACK), 1, 1))); BufferedImage expected = new BufferedImage(2, 1, BufferedImage.TYPE_INT_ARGB); expected.setRGB(1, 0, BLACK.getRGB()); assertTrue(bufferedImagesEqual(expected, ImageUtil.resizeCanvas(oneByOne(BLACK), 2, 1))); expected = new BufferedImage(1, 2, BufferedImage.TYPE_INT_ARGB); expected.setRGB(0, 1, BLACK.getRGB()); assertTrue(bufferedImagesEqual(expected, ImageUtil.resizeCanvas(oneByOne(BLACK), 1, 2))); }
@Test public void resizeCanvas() { assert(bufferedImagesEqual(centeredPixel(BLACK), ImageUtil.resizeCanvas(oneByOne(BLACK), 3, 3))); assert(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.resizeCanvas(oneByOne(BLACK), 1, 1))); assert(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.resizeCanvas(centeredPixel(BLACK), 1, 1))); BufferedImage expected = new BufferedImage(2, 1, BufferedImage.TYPE_INT_ARGB); expected.setRGB(1, 0, BLACK.getRGB()); assert(bufferedImagesEqual(expected, ImageUtil.resizeCanvas(oneByOne(BLACK), 2, 1))); expected = new BufferedImage(1, 2, BufferedImage.TYPE_INT_ARGB); expected.setRGB(0, 1, BLACK.getRGB()); assert(bufferedImagesEqual(expected, ImageUtil.resizeCanvas(oneByOne(BLACK), 1, 2))); }