image::Handle::from_rgba not working
laullon opened this issue · comments
German Laullon commented
Is there an existing issue for this?
- I have searched the existing issues.
Is this issue related to iced?
- My hardware is compatible and my graphics drivers are up-to-date.
What happened?
I have this code:
use iced::{
widget::{column, image, text, Column, Image},
ContentFit, Length,
};
fn main() -> iced::Result {
tracing_subscriber::fmt::init();
iced::program("Iced example", Window::update, Window::view).run()
}
#[derive(Default)]
struct Window {}
#[derive(Debug)]
pub enum Message {}
impl Window {
pub fn view(&self) -> Column<Message> {
let pixels = [0xff, 1, 0, 0].repeat(10000);
let screen = image::Handle::from_rgba(100, 100, pixels);
let screen = Image::<image::Handle>::new(screen)
.content_fit(ContentFit::Contain)
.width(Length::Fill)
.height(Length::Fill);
column![text("Hello").size(50), screen, text("World !!").size(50)]
}
pub fn update(&mut self, _: Message) {}
}
What is the expected behavior?
I expect to have a "red" image between the two text.
Version
master
Operating System
macOS
Do you have any log output?
Executing task: cargo run --package rust_test --bin rust_test
Compiling rust_test v0.1.0 (/Users/laullon/dev/rust_test)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.63s
Running `target/debug/rust_test`
2024-05-08T21:36:44.773012Z INFO iced_wgpu::window::compositor: Settings {
present_mode: AutoVsync,
backends: Backends(
VULKAN | GL | METAL | DX12 | BROWSER_WEBGPU,
),
default_font: Font {
family: SansSerif,
weight: Normal,
stretch: Normal,
style: Normal,
},
default_text_size: Pixels(
16.0,
),
antialiasing: None,
}
2024-05-08T21:36:44.778160Z INFO wgpu_core::instance: Adapter Metal AdapterInfo { name: "Apple M3", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2024-05-08T21:36:44.778608Z INFO iced_wgpu::window::compositor: Available adapters: [
AdapterInfo {
name: "Apple M3",
vendor: 0,
device: 0,
device_type: IntegratedGpu,
driver: "",
driver_info: "",
backend: Metal,
},
]
2024-05-08T21:36:44.779310Z INFO wgpu_core::instance: Adapter Metal AdapterInfo { name: "Apple M3", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2024-05-08T21:36:44.779408Z INFO iced_wgpu::window::compositor: Selected: AdapterInfo {
name: "Apple M3",
vendor: 0,
device: 0,
device_type: IntegratedGpu,
driver: "",
driver_info: "",
backend: Metal,
}
2024-05-08T21:36:44.779490Z INFO iced_wgpu::window::compositor: Available formats: Copied {
it: Iter(
[
Bgra8UnormSrgb,
Bgra8Unorm,
Rgba16Float,
Rgb10a2Unorm,
],
),
}
2024-05-08T21:36:44.779501Z INFO iced_wgpu::window::compositor: Available alpha modes: [
Opaque,
PostMultiplied,
]
2024-05-08T21:36:44.779529Z INFO iced_wgpu::window::compositor: Selected format: Bgra8UnormSrgb with alpha mode: PostMultiplied
2024-05-08T21:36:45.059536Z INFO cosmic_text::font::system: Parsed 1295 font faces in 222ms.