Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics2D;
- import java.awt.Rectangle;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- public class TestImage {
- public static void main(String[] args) {
- BufferedImage bi = new BufferedImage(800, 14*40, BufferedImage.TYPE_INT_RGB);
- Graphics2D g2 = bi.createGraphics();
- g2.setBackground(Color.blue);
- for ( int i = 0; i < 40; i += 2) {
- g2.clearRect(0, 14*i, 800, 14);
- }
- bi.getGraphics().drawString("Hello World!", 200, 200);
- try {
- File outputfile = new File("saved.png");
- ImageIO.write(bi, "png", outputfile);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment