mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 11:28:30 +08:00
Add a dropdown for resource selection and adopt it in the 'Image' node (#4543)
* Add a dropdown for resource selection and adopt it in the Image node * Route every image upload through a new ResourceUpload handler with desktop support and migrate wired 'Image' node inputs * Show each resource's user count in the resource picker dropdown * Send a picked resource file to the document that requested it, list every non-font resource in the picker, and link sibling message docs
This commit is contained in:
@@ -251,13 +251,17 @@ pub fn empty_image(_: impl Ctx, transform: Item<DAffine2>, color: Item<Color>) -
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
pub fn image<'a: 'n>(_: impl Ctx, resource: Item<Resource>) -> Item<Raster<CPU>> {
|
||||
pub fn image<'a: 'n>(
|
||||
_: impl Ctx,
|
||||
_primary: (),
|
||||
/// The image file to display.
|
||||
#[widget(ParsedWidgetOverride::Custom = "image_file")]
|
||||
resource: Item<Resource>,
|
||||
) -> Item<Raster<CPU>> {
|
||||
let resource = resource.into_element();
|
||||
let image_data = resource.as_ref();
|
||||
|
||||
let Some(image) = ::image::load_from_memory(image_data).ok() else {
|
||||
return Item::default();
|
||||
};
|
||||
let Some(image) = ::image::load_from_memory(image_data).ok() else { return Item::default() };
|
||||
let image = image.to_rgba32f();
|
||||
let image = Image {
|
||||
data: image.chunks(4).map(|pixel| Color::from_gamma_srgb_channels(pixel[0], pixel[1], pixel[2], pixel[3])).collect(),
|
||||
|
||||
Reference in New Issue
Block a user