bufferedimage - Combining PNG Images Java -
i trying loop through file of png images , stitch them form 1 image. have gotten work without using loop , combining 2 images file. assuming looping isn't working. images located in file called "images". appreciate input!
file file = new file("images"); file [] morefile = file.listfiles(); string [] images = new string [morefile.length]; for(int =0; <images.length; i++) {images[i] = morefile[i].getname(); } int x = 0; int y = 0; bufferedimage result = new bufferedimage( controller.getsize().width*2, controller.getsize().height, //work these out bufferedimage.type_int_rgb); graphics g = result.getgraphics(); for(string image : images){ system.out.println(image); file path = new file("images"); try{imageio.read(new file(path, image)); system.out.println("it goes here"); bufferedimage bi = new bufferedimage((2*510),(2*439),bufferedimage.type_int_argb); bi =imageio.read(new file(path, image)); g.drawimage(bi, x, y, null); g.dispose(); /// system.out.println(dafuck); x += bi.getwidth(); if(x > result.getwidth()){ x = 0; y += bi.getheight(); } }catch (exception e) { system.out.println("is exception>?"); } } try { imageio.write(result,"png",new file("results")); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }
Comments
Post a Comment