/** * java mosaic multiple pictures * * @param pics * @param type * @param dst_pic * @return/public static Boolean merge (S)
Tring[] Pics, String type, string dst_pic) {int len = pics.length;
if (Len < 1) {System.out.println ("Pics len < 1");
return false;
} file[] src = new File[len];
bufferedimage[] images = new Bufferedimage[len];
int[][] imagearrays = new int[len][];
for (int i = 0; i < len; i++) {try {src[i] = new File (pics[i]);
Images[i] = Imageio.read (Src[i]);
catch (Exception e) {e.printstacktrace ();
return false;
int width = images[i].getwidth ();
int height = images[i].getheight (); Imagearrays[i] = new Int[width * height];//reads RGB imagearrays[i from picture] = Images[i].getrgb (0, 0, width, height, image
Arrays[i], 0, width);
int dst_height = 0;
int dst_width = Images[0].getwidth (); for (int i = 0; i < images.length i++) {dst_width = dst_width > Images[i].getwidth ()? dst_width:imageS[i].getwidth ();
Dst_height + + images[i].getheight ();
} System.out.println (Dst_width);
System.out.println (Dst_height);
if (Dst_height < 1) {System.out.println ("Dst_height < 1");
return false;
///Generate new picture try {//Dst_width = Images[0].getwidth ();
BufferedImage imagenew = new BufferedImage (Dst_width, Dst_height, Bufferedimage.type_int_rgb);
int height_i = 0; for (int i = 0; i < images.length i++) {imagenew.setrgb (0, Height_i, Dst_width, Images[i].getheight (), imag
Earrays[i], 0, dst_width);
Height_i + + images[i].getheight ();
} file outfile = new file (dst_pic);
Imageio.write (imagenew, type, outfile);//Write Picture} catch (Exception e) {e.printstacktrace ();
return false;
return true; }