java - Image transformation results in a red image? -
i trying transform image flipping horizontally , resizing it. problem when transformation done picture's colors weird, has gotten reddish tone. possible fix somehow, think read somewhere might bug in awt library not sure?
here code:
import java.awt.graphics2d; import java.awt.geom.affinetransform; import java.awt.image.affinetransformop; import java.awt.image.bufferedimage; import java.io.file; import java.io.ioexception; import javax.imageio.imageio; public class localimagesizeflip { public static void main(string[] args) { bufferedimage img = null; try { img = imageio.read(new file("c:\\picture.jpg")); affinetransform tx = affinetransform.getscaleinstance(1, -1); tx.translate(0, -img.getheight(null)); affinetransformop op = new affinetransformop(tx, affinetransformop.type_nearest_neighbor); img = op.filter(img, null); img = resize(img, 100, 75); file newfile = new file("newpicture.jpg"); imageio.write(img, "jpeg", newfile); } catch (ioexception e) { e.printstacktrace(); } } private static bufferedimage resize(bufferedimage image, int width, int height) { bufferedimage resizedimage = new bufferedimage(width, height, bufferedimage.type_int_argb); graphics2d g = resizedimage.creategraphics(); g.drawimage(image, 0, 0, width, height, null); g.dispose(); return resizedimage; } }
having image develop tint means image being rendered using wrong colorspace, adobe rgb vs. srgb being perennial favorite. try changing type_int_argb type_int_rgb in code.
Comments
Post a Comment