码迷,mamicode.com
首页 > 其他好文 > 详细

e669. 绘制缓冲图像

时间:2018-09-02 23:49:47      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:osi   red   lsp   style   table   rap   col   idt   link   

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 确定图像中是否有透明像素), 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();

 

Related Examples

e669. 绘制缓冲图像

标签:osi   red   lsp   style   table   rap   col   idt   link   

原文地址:https://www.cnblogs.com/borter/p/9575510.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!