1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Images service, widget and other types.
//!
//! # Image
//!
//! The [`Image!`](struct@Image) widget is the primary way of presenting images, the example below defines
//! a repeating pattern image as the window background, the image source is embedded in this case, see [`ImageSource`]
//! for other supported sources.
//!
//! ```
//! use zng::prelude::*;
//! # let _scope = APP.defaults();
//! # macro_rules! include_bytes { ($tt:tt) => { &[0u8] } }
//!
//! # let _ =
//! Window! {
//! widget::background = Image! {
//! source = include_bytes!("../res/image/pattern.png");
//! img_fit = zng::image::ImageFit::None;
//! img_repeat = true;
//! }
//! }
//! # ;
//! ```
//!
//! # Mask
//!
//! Mask images are loaded just like normal images, the [`mask::mask_image`](fn@mask::mask_image) property
//! can be set on any widget to apply a mask to it. The example below applies a mask to a button, by
//! default the mask uses the alpha channel, see [`mask`] for more details.
//!
//! ```
//! use zng::{prelude::*, image::mask};
//! # let _scope = APP.defaults();
//! # macro_rules! include_bytes { ($tt:tt) => { &[0u8] } }
//!
//! # let _ =
//! Button! {
//! mask::mask_image = include_bytes!("../res/image/star.png");
//! }
//! # ;
//! ```
//!
//! # Service
//!
//! The [`IMAGES`] service manages image loading, the image cache and image rendering. Image decoding is
//! implemented by the view-process, for this reason to get image with actual pixels the service must be
//! used in a headed app or headless app with renderer, in a headless app without renderer all images are
//! a placeholder dummy.
//!
//! The images service also define security limits, the [`IMAGES.limits`](fn@IMAGES::limits)
//! variable to configure these limits. See [`ImageLimits::default`] for the defaults.
//!
//! ```
//! use zng::{prelude::*, image};
//! # let _scope = APP.defaults();
//!
//! image::IMAGES.limits().modify(|l| {
//! let l = l.to_mut();
//! l.allow_uri = image::UriFilter::allow_host("httpbin.org");
//! l.max_encoded_len = 1.megabytes();
//! l.max_decoded_len = 10.megabytes();
//! });
//! ```
//!
//! The example above changes the global limits to allow image downloads only from an specific host and
//! only allow images with sizes less or equal to 1 megabyte and that only expands to up to 10 megabytes
//! after decoding.
//!
//! # Full API
//!
//! See [`zng_ext_image`] for the full image API and [`zng_wgt_image`] for the full widget API.
pub use ;
pub use UriFilter;
pub use ;
/// Mask image properties.
///
/// See [`zng_wgt_image::mask`] for the full API.