Java combine images one on top of the other -


i want create 1 image 2 images first 1 above second one:

---------------- image1 ---------------- ---------------- image2 ---------------- 

so output image have have height , width of image 1 + image 2:

here code:

private void combainimages(list<string> imagelist, string combainedimages)             throws ioexception {         //paths images         string apath = imagelist.get(0);         string bpath = imagelist.get(1);         //as image         bufferedimage = imageio.read(new file(apath));         bufferedimage b = imageio.read(new file(bpath));          int aw = a.getwidth(); //551         int ah = a.getheight(); //600          int bw = b.getwidth(); //551         int bh = b.getheight(); //600          bufferedimage c = new bufferedimage(a.getheight() + b.getheight(),                 a.getwidth() + b.getwidth(), bufferedimage.type_int_argb);         // 1200 1102         graphics g = c.getgraphics();         g.drawimage(a, 0, 0, null);         g.drawimage(b, 0, a.getwidth(), null);         imageio.write(c, "png", new file(combainedimages));     } 

the output big space between 2 image.

thanks help.

you're choosing y position based on width rather height.

g.drawimage(b, 0, a.getwidth(), null);  

should be

g.drawimage(b, 0, a.getheight(), null); 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -