Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.imageio.ImageIO;
- import java.awt.*;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- public class TransparentPNG {
- public static void main(String[] args) throws IOException {
- BufferedImage bi = ImageIO.read(new FileInputStream(new File("/home/oxodao/Small-mario.png")));
- for (int y = 0; y < bi.getHeight(); y++) {
- for (int x = 0; x < bi.getWidth(); x++) {
- Color c = new Color(bi.getRGB(x, y), true);
- if (c.getAlpha() == 0)
- bi.setRGB(x, y, (new Color(13, 160, 0)).getRGB());
- }
- }
- ImageIO.write(bi, "png", new File("/home/oxodao/small_green.png"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement