java - fusion of images without using of buffereimage -
i merge many images one, instantiate bufferedimage :
for (int i=0;i<listimagetmp.size();i++) { if (listimagetmp.get(i)!=null) { image src = listimagetmp.get(i); bufferedimage bimage = new bufferedimage(src.getwidth(null), src.getheight(null), bufferedimage.type_int_rgb); // draw image on buffered image graphics2d bgr = bimage.creategraphics(); bgr.drawimage(src, 0, 0, null); bgr.dispose(); int[] pixels = ((databufferint) bimage.getraster().getdatabuffer()).getdata(); for(int x =0; x<bimage.getwidth();x++){ for(int y =0; y<bimage.getheight();y++){ int newrgbvalue = pixels[y * bimage.getwidth() + x]; int oldvalue = bufferedimage.getrgb(x, y); if((newrgbvalue > oldvalue) && (oldvalue != -16777216) && (newrgbvalue == 16777215)){ newrgbvalue = oldvalue; } bufferedimage.setrgb(x, y, newrgbvalue); } } } } node = new pimage(bufferedimage); bufferedimage.flush(); bufferedimage.getgraphics().dispose(); bufferedimage = null; pimage node2 = (pimage) node.clone(); // clonage node = null; getcanvas().getlayer().addchild(node2);
and have heap space memory error. need know: how can fix it?
Comments
Post a Comment