Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion utility functions don't convert bit depth #2

Closed
carlosmn opened this issue May 23, 2022 · 4 comments
Closed

Conversion utility functions don't convert bit depth #2

carlosmn opened this issue May 23, 2022 · 4 comments

Comments

@carlosmn
Copy link

Description

I was trying to render an image with a custom renderer and my image kept not being rendered even though the write_image method returns success. It turns out (at least my "Original V2") the image does not work if it's 16-bit but does if it's 8-bit.

Steps to Reproduce

Take a 16-bit PNG image, e.g. the lightbulb from https://www.home-assistant.io/integrations/light/ to put into a component and modify the example in this repo to load that image instead of the gradient.

            let image = load_image(core.core().image_size, "XXX/Downloads/lightbulb.png").unwrap();
            let tex = convert_image(&Kind::OriginalV2, image);
            streamdeck.write_image(&tex).ok();

This succeeds but the device does not show anything. It does work if I change the bit depth to 8 and then load the same module. If I do

            let image = load_image(core.core().image_size, "XXX/Downloads/lightbulb.png").unwrap();
            let rgba8 = DynamicImage::ImageRgba8(image.to_rgba8());
            let tex = convert_image(&Kind::OriginalV2, rgba8);
            let written = streamdeck.write_image(&tex);

instead, then that works.

Expected behavior

The conversion utility methods should take care of the conversion to 8-bit (or whatever else that we do need). It seems to be that the bit depth is the one difference here.

Screenshots

It'd just be a blank button vs one with anything in it.

@TheJebForge
Copy link
Collaborator

Stream Decks don't support anything else than 8-bit images. load_image is also some legacy code that was left after I refactored how I handle images in Streamduck. But yeah, my utils don't convert to 8 bit and it's a problem, will fix it in near future.

I'll try to explain my codebase good whenever I get to writing documentation for plugin dev

@TheJebForge
Copy link
Collaborator

TheJebForge commented May 23, 2022

Pushed out fixes to this (decided to just do it now), hopefully it works now. The problem did also appear with normal usage of the software, and after fixes, it works as expected.

Everything image related was moved to streamduck-core::image module during development, rendering utils just have some useful things for quickly generating some backgrounds and drawing text

@carlosmn
Copy link
Author

Thanks for the quick turnaround.

load_image is also some legacy code that was left after I refactored how I handle images in Streamduck

I see, it did seem different. Is the expectation that a plugin would add its images when it's first added? Or should it just be up to the user to decide what to use?

@TheJebForge
Copy link
Collaborator

I expect the user to add the images they want, but plugins can also add images. The core reference contains image_collection, by just adding an SDImage into that collection, it will make its way to device config and to the clients. User will be able to delete that image though, because it would seem as if they just uploaded it.

I personally prefer just doing some ascii art for components I define, so user can later decide the looks of the button on their own

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants