Friday, 15 August 2014

java - How to convert an image to greyscale? -


I want to convert only one image to grayscale. But why do I have a completely black image?

  BufferedImage Basic = imageIO.read (url); Buffet image image = new buffard image (original .getWidth (), original GetHeight (), buffed image .tip_bivittarRR); Graphics G = image.getGraphics (); G.drawImage (image, 0, 0, empty); G.dispose ();  

The correct width and height is like the source image, but is completely black ...

You are writing an empty image of yourself.

Change

  g.drawImage (image, 0, 0, empty);  

to

  g.drawImage (original, 0, 0, empty);  

No comments:

Post a Comment