ryankurte / rust-streamdeck

libusb based driver for Elgato StreamDeck devices
Mozilla Public License 2.0
57 stars 24 forks source link

Make DeviceImage data be public #18

Closed TheJebForge closed 2 years ago

TheJebForge commented 2 years ago

I'm currently trying to implement animated images with my project, but the whole overhead that set_button_image introduces makes it impossible. But write_button_image is also blocked since there's no way to construct DeviceImage struct outside of the crate. So I'm requesting this change, so projects like mine can manually prepare a valid byte buffer and push it to streamdeck with this library.

ryankurte commented 2 years ago

howdy thanks for the PR! definitely interested to see how the animation goes when you get there.

would it also work to have a from_raw(v: Vec<u8>) function or do you need access to the underlying buffer? it probably doesn't make a big difference but, it'd be nice to in future think about improving the DeviceData interface.

TheJebForge commented 2 years ago

frow_raw would also work, i just need a way to be able to create DeviceImage struct beforehand and keep it in my collection, so for each frame, I just need to pass the reference to write_button_image. I managed to get 60fps gifs working on my local version of this library https://youtu.be/9-4eT0MoTaU just because i was able to do the processing once and keep passing reference to existing frames.

(Meant DeviceImage, I just have similar struct in my project, brainfart)

ryankurte commented 2 years ago

I managed to get 60fps gifs working on my local version of this library https://youtu.be/9-4eT0MoTaU just because i was able to do the processing once and keep passing reference to existing frames.

oh wow that's amazing!

frow_raw would also work, i just need a way to be able to create DeviceImage struct beforehand and keep it in my collection, so for each frame, I just need to pass the reference to write_button_image

if you're up for swapping this to from_raw i'll get it merged and released?

TheJebForge commented 2 years ago

Does this look good enough?

TheJebForge commented 2 years ago

Looked around and from_raw usually means "from raw pointer", so from_bytes would be more explanatory.

ryankurte commented 2 years ago

looks great, thanks!