rust_minifb icon indicating copy to clipboard operation
rust_minifb copied to clipboard

Support for pixel formats with an alpha channel

Open connorskees opened this issue 2 years ago • 2 comments

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?

connorskees avatar Sep 04 '21 15:09 connorskees

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)

emoon avatar Sep 06 '21 06:09 emoon

I had a bit of a play with different color formats backed by u32s 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

twe4ked avatar Nov 10 '21 03:11 twe4ked