Wednesday 15 August 2012

java - Automatic color fill? -



java - Automatic color fill? -

there not silly issue.. let's say, have lot of black colored png icons (over hundred), may consist of more 1 unconnected elements like:

what want accomplish create set of colors , automatically color(fill black content) graphics, , leave rest parameters unchanged(format/resolution). there library or approach should applied perform task?

thanks

here's little procedure it:

public static void main(string[] args) { final string directorypath = "c:\\images"; final string outputpath = "c:\\images\\out"; final int color = 0x00ff0000; file directory = new file(directorypath); file[] files = directory.listfiles(); if (files == null) { return; } (file file : files) { string extension; int extensionindex = file.getname().lastindexof('.'); if (extensionindex > 0) { extension = file.getname().substring(extensionindex + 1); } else { extension = "bmp"; } bufferedimage image; seek { image = convert(imageio.read(file), bufferedimage.type_int_argb); (int = 0; < image.getwidth(); i++) { (int j = 0; j < image.getheight(); j++) { image.setrgb(i, j, image.getrgb(i, j) | color); } } file newfile = new file(outputpath + "\\" + file.getname()); imageio.write(image, extension, newfile); } grab (ioexception e) { // handle } } }

i used convert method of post: java converting between color models

java android graphics colors

No comments:

Post a Comment