e669. drawing on a buffered image.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 20 行
TXT
20 行
To draw on a buffered image, create a graphics context on the buffered image.
// Create a graphics context on the buffered image
Graphics2D g2d = bimage.createGraphics();
// Draw on the image
g2d.setColor(Color.red);
g2d.fill(new Ellipse2D.Float(0, 0, 200, 100));
g2d.dispose();
If the buffered image supports transparency, (see e661 Determining If an Image Has Transparent Pixels), pixels can be made transparent:
g2d = bimage.createGraphics();
// Make all filled pixels transparent
Color transparent = new Color(0, 0, 0, 0);
g2d.setColor(transparent);
g2d.setComposite(AlphaComposite.Src);
g2d.fill(new Rectangle2D.Float(20, 20, 100, 20));
g2d.dispose();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?