package test; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.imageio.ImageIO; public class Rgb { public List<Integer> getRGB(BufferedImage image, int x, int y) { List<Integer> rgb = new ArrayList<Integer>(); if (image != null && x <= image.getWidth() && y <= image.getHeight()) { for (int h = 0; h < y; h++) { for (int w = 0; w < x; w++) { //获得w,h坐标的颜色 int pixel = image.getRGB(w, h); rgb.add(pixel); } } }
根据存有RGB值的一维数组生成Image
最新推荐文章于 2021-12-15 15:33:43 发布