Skip to content

Instantly share code, notes, and snippets.

@ice1000
Created March 29, 2017 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ice1000/b9d141fdb8d15167c257a2f084f9b4c7 to your computer and use it in GitHub Desktop.
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)
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