日期:2014-05-20 浏览次数:20747 次
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 );
dstCM = src.getColorModel();
return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null);