Read and write images in pixels in java -
i trying read , write grayscale image using bufferedimage
. pixels in writing images little bit different source. not image processing stuff. please me find mistake have made in code.
here code
file inimage=new file("source.jpg"); file outimage=new file("out.jpg"); /* code reading image*/ bufferedimage image=imageio.read(inimage); writableraster raster=image.getraster(); /* writing same raster new image */ bufferedimage newimg=new bufferedimage(raster.getwidth(), raster.getheight(),bufferedimage.type_byte_gray); newimg.setdata(raster); imageio.write(newimg, "jpg", outimage);
i'm sure original image not of type type_byte_gray
. suggest output same image type input one:
bufferedimage newimg = new bufferedimage(raster.getwidth(), raster.getheight(), image.gettype());
Comments
Post a Comment