views:

67

answers:

1

hi guys, i'm trying to create a program that generates images for use as multi-screen backgrounds, i'm doing this targeted at windows (in my case, 7 so that basically i can get images to change without seeing the same image on two different screens)

in my program, i read multiple image input files and compile them into a single output image that is the total size of the desktop (including black areas not seen on screens)

my question is, what class/methods are good for cropping/resizing/pasting into a new image in java because i'm coming across so many image manipulation classes and they all seem to do one tiny thing.

i will not be modifying any of the images beyond resize or crop and putting it into a certain position in the new (initially blank) image.

code can be made available as i plan to release it at some later point for whoever may like/need it.

thank you in advance, if this question has been answered, my apologies but i DID have a look around.

+1  A: 

I do not know if this is the best method, but it is quite easy:

// load an image
Image image = javax.imageio.ImageIO.read(new File("someimage.png");
// resize it
image = image.getScaledInstance(100, 100, Image.SCALE_SMOOTH);
// create a new image to render to
BufferedImage newimg = new BufferedImage(200,100,BufferedImage.TYPE_INT_ARGB);
// get graphics to draw..
Graphics2D graphics =newimg.createGraphics();
//draw the other image on it
graphics.drawImage(image,0,0,null);
graphics.drawImage(image,100,0,null);
graphics.fillOval(20,20,40,40); //making it a bit ugly ;)
//export the new image
ImageIO.write(newimg,"png",new File("output.png"));
//done!

For simplicity I dropped all checks, exception handling, etc.

Ishtar
i think i can work with this as a guide, thank you very much!
ara_h13