daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top