-
Notifications
You must be signed in to change notification settings - Fork 0
Alpha blending
kkrmno edited this page May 6, 2020
·
2 revisions
Image credit: NASA
Overlaying mars on top of the earth using a bit of transparency yields:
require "imgrb"
image_bg = Imgrb::Image.new("nasa_earth_small.png")
image_fg = Imgrb::Image.new("nasa_mars_small.png")
alpha = 180 #Out of 255
alpha_channel = Imgrb::Image.new(image_fg.width, image_fg.height, alpha)
image_fg.set_channel(3, alpha_channel)
image_alpha_overlay = image_fg.alpha_over(image_bg)
image_alpha_overlay.save("earth_mars_overlay.png")