你能告诉我为什么像素不会设置为红色吗
Color myColor = new Color(255, 0, 0);
int rgb = myColor.getRGB();
String fileName = Config.IMAGEFILEPATH + "first_nodal_domain "
+ "full.png";
BufferedImage bi = new BufferedImage(AZIMUTH_RES, ELEVATION_RES, BufferedImage.TYPE_USHORT_GRAY);
for (int i = 0; i < AZIMUTH_RES; i++){
for (int j = 0; j < ELEVATION_RES; j++){
bi.setRGB(i,j,(255 << 16) + (255 << 8) + 255);
}
}
for (Point draw: shadedPoints){
bi.setRGB(draw.x, draw.y, rgb);
}
BufferedImage scaledImage = new BufferedImage(
1000, 1000, BufferedImage.TYPE_USHORT_GRAY);
// Paint scaled version of image to new image
Graphics2D graphics2D = scaledImage.createGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics2D.drawImage(bi, 0, 0, 1000, 1000, null);
try {
// write out image to file as .png
ImageIO.write(scaledImage, "png", new File(fileName));
} catch (IOException ex) {
Logger.getLogger(NodalDomainsDrawing.class.getName()).log(Level.SEVERE, null, ex);
}
bi.flush();
提前致谢。