rust_minifb
rust_minifb copied to clipboard
Support for pixel formats with an alpha channel
Hello,
I am wondering if supporting pixel formats other than 0RGB would be out of the scope of this library. I am currently using this library to prototype something that requires support for an alpha channel, and having this available in the windowing library would be very useful.
I see discussion about this in https://github.com/emoon/rust_minifb/issues/101, but would like to clarify thoughts here. Would you be open to a PR implementing this for POSIX?
I think the ideal API would be to have the format specifiable in minifb::WindowOptions
, but that would be a breaking change. Do you have other thoughts for how/where this should be implemented?
Hey,
It depends a bit on what you want the alpha channel to do. In this PR https://github.com/emoon/rust_minifb/pull/164 it makes it possible (on some OSes) that the alpha will blend towards the background of the screen (i.e a transparent window)
I had a bit of a play with different color formats backed by u32
s in a library I wrote a little while back. It introduces a Storage
trait that can be implemented to pack/unpack the RGBA values. The idea might be relevant here.
https://github.com/twe4ked/inku/blob/4898cc2579ad91722e5a413eb33a89be95e0cced/src/lib.rs#L116-L175