展开全部
楼上的基本正确,
问题一:
int[] rgb = new int[3];最好用二维数组
int[] rgb = new int[3][width*height]
问题二:
rgb[0] = (pixel & 0xff0000 ) >> 16 ;
rgb[1] = (pixel & 0xff00 ) >> 8 ;
rgb[2] = (pixel & 0xff );
会把数组内62616964757a686964616fe78988e69d8331333238653965的值覆盖,获得就是最后像素点的RGB值;
我写了一个希望可以帮助到你
package imageReadAndWrite;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageDecoder;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
* JPG File reader/writer. Uses native com.sun libraries (which may deprecate a