bufferedimage - Why is JPG altered on retrieval? - Java -
i trying retrieve jpg image bufferedimage decompose 3d array [red][green][blue] , turn bufferedimage , store under different file-name. looks fine me but, when trying reload 3d array using new file created different values rgb although new image looks fine naked eye. did following.
bufferedimage bi = imageio.read(new file("old.jpg")); int[][][] 1 = getarray(bi); save("kite.jpg", one); bufferedimage bi2 = imageio.read(new file("new.jpg")); int[][][] 2 = getarray(bi2); private void save(string destination, int[][][] in) { try { bufferedimage out = new bufferedimage(in.length, in[0].length, bufferedimage.type_3byte_bgr); (int x=0; x<out.getwidth(); x++) { (int y = 0; y < out.getheight(); y++) { out.setrgb(x, y, new color(in[x][y][0], in[x][y][1], in[x][y][2]).getrgb()); } } file f = new file("name"); imageio.write(out, "jpeg", f); } catch (ioexception e) { system.out.println(e.getmessage()); } } so in example above values arrays one , two holding different.
i guessing there different types of retrieving , restoring images? trying figure out going on day no luck. appreciated.
pretty simple:
jpeg commonly used method of lossy compression digital images
(from wikipedia). each time image compressed, image altered reduce file-size. in fact repeating steps of decompression , compression several hundred times alters image point entire image turns plain gray area in cases. there few compressions work lossless, operation-modes alter image.
Comments
Post a Comment