Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import javax.imageio.ImageIO;
  2. import java.awt.*;
  3. import java.awt.image.BufferedImage;
  4. import java.io.File;
  5. import java.io.FileInputStream;
  6. import java.io.IOException;
  7.  
  8. public class TransparentPNG {
  9.  
  10. public static void main(String[] args) throws IOException {
  11.  
  12. BufferedImage bi = ImageIO.read(new FileInputStream(new File("/home/oxodao/Small-mario.png")));
  13.  
  14. for (int y = 0; y < bi.getHeight(); y++) {
  15. for (int x = 0; x < bi.getWidth(); x++) {
  16. Color c = new Color(bi.getRGB(x, y), true);
  17.  
  18. if (c.getAlpha() == 0)
  19. bi.setRGB(x, y, (new Color(13, 160, 0)).getRGB());
  20. }
  21. }
  22.  
  23.  
  24. ImageIO.write(bi, "png", new File("/home/oxodao/small_green.png"));
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement