-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Image::from_bytes factory #76
Comments
I’ve also wanted this feature and wouldn’t mind implementing. Feel free to assign the task to me. |
Or generate it procedurally. |
Thanks for the idea! Yes, I think this is a basic use case we should satisfy. However, it's not as straightforward as it may seem. The main challenge here is to avoid decompressing and uploading the image data to the GPU every time we draw. In other words, we need to keep track of the image somehow. The current renderer uses the I think we could leverage For now, a way to implement this would be to attach a unique id together with the image bytes and use that as a key in the renderer cache. A way to make this explicit would be with an opaque const EMBEDDED_IMAGE: image::Data = image::Data::from_bytes(
"my_id",
include_bytes!("image.png"),
);
const FILE_IMAGE: image::Data = image::Data::from_path("resources/ferris.png"); However, I am not a fan of using stringified global identifiers, as they open the door for many pesky bugs (think what would happen if an identifier is used twice with different bytes). Overall, I think the problem is telling us that an What are your thoughts? |
I also want something like Image::from_bytes before. My case is providing a remote url as path, and the image will be downloaded and loaded .. As for "Canvas" widget, It's a great idea for both image and mesh data. Do you have any plan for that? |
@hecrj why not use some quick hash on the image bytes as the cache identifier? |
My use case is for fractal art and other procedural art, where there never was an "original image" and it's all procedurally generated. Having a GUI library for procedural art would be amazing, because a lot of procedural art is fiddling with settings. Right now I do that via command line arguments, but it would be great if I could use checkboxes, type numbers into fields, etc and get realtime updates. There are a few tiers of features I can think of that would make my life easier, ordered from least work to most work.
It sounds like you're already open to #1, and #2 doesn't seem too crazy imo. I have no idea how much work #3 and #4 would take. |
@piaoger Yes! A
@bingo347 I think that could work. We will need to make
@ejmahler This reminds me a lot of the I think all the features you list, besides maybe the first one, are meant to be satisfied by some kind of canvas widget that exposes an advanced graphics API for drawing. A widget that would only be available in GPU-accelerated renderers. I think #32 (or a similar custom widget) should satisfy your use cases in the long run. You seem to be way more experienced than me with graphics programming and I'd love to hear any suggestions you may have about a possible API and its implementation, while learning more about your use cases. |
Hello!
I think a good idea, to have Image::from_bytes factory. This will allow to include the image bytes in an executable binary or load it manually.
Example:
The text was updated successfully, but these errors were encountered: