| | |
| | | |
| | | |
| | | /** |
| | | * 课程超市工具类 |
| | | * 课程超市工具类 |
| | | * @author xiadehu |
| | | * |
| | | */ |
| | |
| | | */ |
| | | public static BufferedImage drawPng(char letter,Color bgColor){ |
| | | |
| | | //初始化画布 |
| | | //初始化画布 |
| | | int width=120; |
| | | int height = 120; |
| | | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
| | |
| | | g2d.dispose(); |
| | | g2d = image.createGraphics(); |
| | | |
| | | //背景 |
| | | //背景 |
| | | g2d.setColor(bgColor); |
| | | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | double centerX = width/2; |
| | |
| | | circle.setFrameFromCenter(centerX, centerY, centerX + radius, centerY+ radius); |
| | | g2d.fill(circle); |
| | | |
| | | //文字 |
| | | //文字 |
| | | g2d.setColor(new Color(255,255,255)); |
| | | int textSize = 64; |
| | | |
| | | Font font = new Font("微软雅黑", Font.PLAIN, textSize); |
| | | Font font = new Font("微软雅黑", Font.PLAIN, textSize); |
| | | g2d.setFont(font); |
| | | FontMetrics metrics = g2d.getFontMetrics(); |
| | | |
| | |
| | | |
| | | g2d.drawString(String.valueOf(letter), x, y); |
| | | |
| | | //释放 |
| | | //释放 |
| | | g2d.dispose(); |
| | | |
| | | return image; |