tags:

views:

21

answers:

1

how can i manipulate pixel values of a loaded image then save portion of that image into a new image(1 image per word).i found several example regarding saving or loading image but i cant understand how can i save image portion???i am trying to do it with java

+1  A: 

I didn't tried it for myself. But studying this and that page leads me to this code:

 BufferedImage im = ImageIO.read(new File("in.jpg"));
 // now manipulate image
 ...
 // now get only a part of it
 Raster raster = im.getData(new Rectangle(xOffset, yOffset, width, height));
 BufferedImage im2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
 im2.setData(raster);
 ImageIO.write(im2, "jpg", new File("out.jpg"));
Karussell