java - Cant use setRGB() to write to png -
public static void main(string[] args) { string finalhex = ""; string input = "hello there sir."; int pixelx = -1; int pixely = 0; try{ bufferedimage bi = new bufferedimage(64, 64, bufferedimage.type_int_argb); file out = new file("saved.png"); if(out.exists()==false){ imageio.write(bi, "png", out); system.out.println("png created"); }else system.out.println("error: png there"); (int = 0;i < input.length(); i++){ char result = input.charat(i); int ascii = (int) result; string num = integer.tohexstring(ascii).touppercase(); if(finalhex.length()==6){ system.out.println(finalhex); pixelx += 1; finalhex=("#"+finalhex); color c = color.decode(finalhex); int rgb = c.getrgb(); system.out.println(rgb); if(pixelx==63){ pixelx=0; pixely+=1; } bi.setrgb(pixelx, pixely, rgb); finalhex=""; } finalhex+=num; } }catch(ioexception e){ system.out.println("error: welp... screwed up."); } }
i trying use convert text png image cant write png file. not experienced in area if me out appreciated. :)
you should add imageio.write(bi, "png", out);
after end of for(int = 0;i < input.length(); i++){...}
program write colored pixels want?? example: result picture
Comments
Post a Comment