Java examples for 2D Graphics:Color RGB
Brightening or Darkening an RGB Buffered Image
import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.RescaleOp; import javax.swing.ImageIcon; public class Main { public void m() throws Exception { // Brighten the image by 30% float scaleFactor = 1.3f; RescaleOp op = new RescaleOp(scaleFactor, 0, null); BufferedImage bufferedImage = null; bufferedImage = op.filter(bufferedImage, null); // Darken the image by 10% scaleFactor = .9f;/*from ww w . j av a2 s. c o m*/ op = new RescaleOp(scaleFactor, 0, null); bufferedImage = op.filter(bufferedImage, null); // Get non-RGB image Image image = new ImageIcon("image.gif").getImage(); // Create an RGB buffered image BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); // Copy non-RGB image to the RGB buffered image Graphics2D g = bimage.createGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); } }