Guest User

Untitled

a guest
Feb 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics2D;
  3. import java.awt.Rectangle;
  4. import java.awt.image.BufferedImage;
  5. import java.io.File;
  6. import java.io.IOException;
  7.  
  8. import javax.imageio.ImageIO;
  9.  
  10.  
  11. public class TestImage {
  12.  
  13. public static void main(String[] args) {
  14. BufferedImage bi = new BufferedImage(800, 14*40, BufferedImage.TYPE_INT_RGB);
  15. Graphics2D g2 = bi.createGraphics();
  16. g2.setBackground(Color.blue);
  17. for ( int i = 0; i < 40; i += 2) {
  18. g2.clearRect(0, 14*i, 800, 14);
  19. }
  20.  
  21.  
  22.  
  23.  
  24.  
  25. bi.getGraphics().drawString("Hello World!", 200, 200);
  26. try {
  27. File outputfile = new File("saved.png");
  28. ImageIO.write(bi, "png", outputfile);
  29. } catch (IOException e) {
  30. e.printStackTrace();
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment