package pl.vgtworld.imagedraw.filters.matrix;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;

class ImageEdgeResizeHelper {
	
	BufferedImage addEdgesToImage(BufferedImage sourceImage, int edgeSize) {
		BufferedImage finalImage = new BufferedImage(
				sourceImage.getWidth() + 2 * edgeSize,
				sourceImage.getHeight() + 2 * edgeSize,
				sourceImage.getType()
				);
		Graphics2D graphics = finalImage.createGraphics();
		graphics.drawImage(sourceImage, edgeSize, edgeSize, null);
		for (int i = 1; i <= edgeSize; ++i) {
			graphics.copyArea(0, edgeSize, finalImage.getWidth(), 1, 0, -i);
			graphics.copyArea(0, sourceImage.getHeight() + edgeSize - 1, finalImage.getWidth(), 1, 0, i);
			graphics.copyArea(edgeSize, 0, 1, finalImage.getHeight(), -i, 0);
			graphics.copyArea(sourceImage.getWidth() + edgeSize - 1, 0, 1, finalImage.getWidth(), i, 0);
		}
		
		graphics.dispose();
		save(finalImage);
		return finalImage;
	}

	//TODO remove
	private void save(BufferedImage finalImage) {
		try {
			ImageIO.write(finalImage, "jpg",  new java.io.File("/home/vgt/Pictures/test/output.jpg"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}

@@ -108,67 +108,8 @@
 age;
-%0Aimport java.io.IOException;%0A%0Aimport javax.imageio.ImageIO;
 %0A%0Acl
@@ -872,11 +872,8 @@
 %09%09%7D%0A
-%09%09%0A
 %09%09gr
@@ -894,28 +894,8 @@
 ();%0A
-%09%09save(finalImage);%0A
 %09%09re
@@ -919,269 +919,6 @@
 %09%7D%0A%0A
-%09//TODO remove%0A%09private void save(BufferedImage finalImage) %7B%0A%09%09try %7B%0A%09%09%09ImageIO.write(finalImage, %22jpg%22,  new java.io.File(%22/home/vgt/Pictures/test/output.jpg%22));%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%09%0A
 %7D%0A

Remove unused code.