jay3332 / ril

Rust Imaging Library: A high-level imaging crate for Rust.
https://crates.io/crates/ril
MIT License
81 stars 10 forks source link

Paste RGBA image over another RGBA image without completely overwriting pixels? #32

Open HyperCodec opened 5 months ago

HyperCodec commented 5 months ago

I have an image with a transparent background that I'd like to paste over another, but doing so sets all the pixels layered under that background area to fully transparent instead of just not affecting those pixels.

Is there a part of the API to implement this sort of blending? If not (and not planned to be added) , how might I implement it manually?

HyperCodec commented 5 months ago

I figured out alpha compositioning on my own but I will keep this issue open as a request to make it part of the library.

jay3332 commented 5 months ago

You must paste the image with an alpha mask (Paste::with_mask)

jay3332 commented 5 months ago

You can also use a paste overlay mode of OverlayMode::Merge