一种方法的示例:
// Create the new image needed
img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB );
for ( int rc = 0; rc < height; rc++ ) {
for ( int cc = 0; cc < width; cc++ ) {
// Set the pixel colour of the image n.b. x = cc, y = rc
img.setRGB(cc, rc, Color.BLACK.getRGB() );
}//for cols
}//for rows
Run Code Online (Sandbox Code Playgroud)
然后从重写的paintComponent(Graphics g)中
((Graphics2D)g).drawImage(img, <args>)
Run Code Online (Sandbox Code Playgroud)
由 Bufferedimage 表示..
我建议BufferedImage为此,显示..
..或者类似的东西,您设置单个像素的颜色,然后将其渲染到屏幕上。
..在a-如这个答案JLabel中所示。

当然,一旦我们有了 的实例BufferedImage,我们就可以setRGB(..)。
| 归档时间: |
|
| 查看次数: |
21919 次 |
| 最近记录: |