国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

App下載
首頁javaimageJava Graphics - 如何創(chuàng)建Grayscaled圖像

Java Graphics - 如何創(chuàng)建Grayscaled圖像

我們想知道如何創(chuàng)建Grayscaled圖像。
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class Main {
  public static void main(String[] args) throws IOException {

    int width = 100;// width of your image
    int height = 100; // height of your image

    BufferedImage img = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_RGB);
    for (int x = 0; x < width; ++x) {
      for (int y = 0; y < height; ++y) {
        int grayscale = 123;
        int colorValue = grayscale | grayscale << 8 | grayscale << 16;
        img.setRGB(x, y, colorValue);
      }
    }
    ImageIO.write(img, "png", new File("c:/Java_Dev/output.png"));
  }
}