62,634
社区成员




try {
FileInputStream fileInputStream = new FileInputStream(new File("D:\\test\\note1\\1.mp3"));
AudioStream as = new AudioStream(fileInputStream);
AudioPlayer.player.start(as);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(img != null){
bufferedImage = new BufferedImage(img.getWidth(this), img.getHeight(this), BufferedImage.TYPE_INT_ARGB);
g2d = bufferedImage.createGraphics();
g2d.drawImage(img, 0, 0, this);
for(int i = 0;i < img.getWidth(this);++i){
for(int j = 0;j < img.getHeight(this);++ j){
int pixel = bufferedImage.getRGB(i, j);
int a = (pixel & 0xff000000) >> 24;
int r = (pixel & 0xff0000) >> 16;
int g = (pixel & 0xff00) >> 8;
int b = (pixel & 0xff);
int grayPixel = (r+g+b)/3;
Color c = new Color(grayPixel, grayPixel, grayPixel);
bufferedImage.setRGB(i, j, c.getRGB());
}
}
}