e680. 使三元色图像变明变暗
Posted borter
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了e680. 使三元色图像变明变暗相关的知识,希望对你有一定的参考价值。
This example demonstrates how to brighten or darken an RGB buffered image by scaling the red, green, and blue values in the image.
// To create a buffered image, see e666 创建缓冲图像 // Brighten the image by 30% float scaleFactor = 1.3f; RescaleOp op = new RescaleOp(scaleFactor, 0, null); bufferedImage = op.filter(bufferedImage, null); // Darken the image by 10% scaleFactor = .9f; op = new RescaleOp(scaleFactor, 0, null); bufferedImage = op.filter(bufferedImage, null);
If the image is not an RGB image, the following code converts a non-RGB image to an RGB buffered image:
// 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();
Related Example |
以上是关于e680. 使三元色图像变明变暗的主要内容,如果未能解决你的问题,请参考以下文章