iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.93k stars 1.18k forks source link

Add image format options to reduce code bloat #376

Closed valpackett closed 3 years ago

valpackett commented 4 years ago

The image crate with default options is the absolute leader in code size:

 File  .text     Size Crate
 5.7%  14.6% 364.0KiB image
 4.6%  12.0% 297.3KiB wgpu_native
 3.8%   9.9% 246.5KiB std
 3.5%   8.9% 222.1KiB usvg
 2.6%   6.8% 170.0KiB iced_wgpu

I don't need to support ico, bmp, tga, hdr, dxt, dds, farbfeld and so on in a program that would only ever decode PNGs :)

It's pretty straightforward to add

[features]
png = ["image/png"]
# and so on

but for backwards compat, the image feature would have to enable some reasonable default set of formats.

Looks like this can be accomplished using cargo's dependency rename thing (e.g. image = { … package = "image_rs" }). What do you think?


Ideally, there should be an option to not use image at all and just provide raw pixel data. (And with explicit gpu memory management instead of a magical cache :D)

hecrj commented 4 years ago

[...] What do you think?

Sounds good!

Ideally, there should be an option to not use image at all and just provide raw pixel data. (And with explicit gpu memory management instead of a magical cache :D)

We will eventually move Image and Svg to iced_graphics. Exposing internals of specific renderers is also something I have in mind, as it will help with some use cases discussed in #32. We are not ready to write code for this yet, however!