Created
March 29, 2017 16:51
-
-
Save ice1000/b9d141fdb8d15167c257a2f084f9b4c7 to your computer and use it in GitHub Desktop.
it makes an icon's alpha value the same as intellij's one's.
(I used it to make intellij plugin icon)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
import javax.imageio.ImageIO | |
/** | |
* Created by ice1000 on 2017/3/28. | |
* | |
* @author ice1000 | |
*/ | |
fun main(args: Array<String>) { | |
val origin = ImageIO.read(File("lice.png")) | |
val css = ImageIO.read(File("css.png")) | |
val alphaPosition = 0xFF shl 24 | |
val bottomAlpha = css.getRGB(css.width - 1, css.height - 1) and alphaPosition | |
(0..origin.width - 1).forEach { x -> | |
(0..origin.height - 1).forEach { y -> | |
val o = origin.getRGB(x, y) | |
origin.setRGB(x, y, | |
if (y < 9 || x < 1) css.getRGB(x, y) | |
else o + bottomAlpha | |
) | |
} | |
} | |
ImageIO.write(origin, "PNG", File("lice-edited.png")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment