用的是BufferedImage存放图片文件
部分代码如下
public int[] getPixArray(BufferedImage image, int w, int h){
int[] pix=new int[w*h];
int type= image.getType();
if ( type ==BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
return (int [])image.getRaster().getDataElements(0, 0, w, h, pix);
else
return image.getRGB( 0, 0, w, h, pix, 0, w );
//return pix;
}w=image.getWidth();
h=image.getHeight();
pixels=getPixArray(image, w, h);
filterImage=new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
filterImage.setRGB(0, 0, w, h, pixels, 0, w );
原图:

输出变成:

本来不是这样的,可以输出和原图一样的图片,也不知道我做了什么,怎么改都改不回去。
图片 Java
------解决方案--------------------
这个类型,是指图片用的模式,比如色深,或者索引等等。
------解决方案--------------------
要创建相同的颜色表,ColorModel然后设置像素
具体代码如下:
dstCM = src.getColorModel();
return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null);
------解决方案--------------------
BufferedImage.TYPE_XXX或者颜色空间不对?
------解决方案--------------------
H 2楼正解啊,理论是行得通的这个,