ImageIcon source=new ImageIcon(dir+strSource);
int height=source.getIconHeight();
int width=source.getIconWidth();
Image im=source.getImage();
int i;
int[] content=new int[height*width];
PixelGrabber pg=null;
try{
pg = new PixelGrabber(im, 0, 0, width, height, content, 0,
width);
pg.grabPixels();
} catch(Exception ex){ex.printStackTrace();}
try{
for (i = 0; i < content.length; i++);
{
int red = (int)((content[i] >> 16) & 0xff);//这一行ch运行时错误 java.lang.ArrayIndexOutOfBoundsException: 480000 int green = (int)((content[i] >> 8) & 0xff);
int blue = (int)((content[i]) & 0xff);
blue = blue + 20;
if (blue > 255)
blue = 255;
content[i] = (255<< 24) |(red << 16)| (green << 8)|blue;
}
Image pic=createImage(new MemoryImageSource(width,height,content,0,width));
ImageIcon ic=new ImageIcon(pic);
lb.setIcon(ic);
lb.repaint();
}catch(Exception ee)
{ee.printStackTrace();}
}
int height=source.getIconHeight();
int width=source.getIconWidth();
Image im=source.getImage();
int i;
int[] content=new int[height*width];
PixelGrabber pg=null;
try{
pg = new PixelGrabber(im, 0, 0, width, height, content, 0,
width);
pg.grabPixels();
} catch(Exception ex){ex.printStackTrace();}
try{
for (i = 0; i < content.length; i++);
{
int red = (int)((content[i] >> 16) & 0xff);//这一行ch运行时错误 java.lang.ArrayIndexOutOfBoundsException: 480000 int green = (int)((content[i] >> 8) & 0xff);
int blue = (int)((content[i]) & 0xff);
blue = blue + 20;
if (blue > 255)
blue = 255;
content[i] = (255<< 24) |(red << 16)| (green << 8)|blue;
}
Image pic=createImage(new MemoryImageSource(width,height,content,0,width));
ImageIcon ic=new ImageIcon(pic);
lb.setIcon(ic);
lb.repaint();
}catch(Exception ee)
{ee.printStackTrace();}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货