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
use crate::prelude::*;
use crate::Texture;
use glib::translate::*;
use glib::IsA;
pub trait TextureExtManual: 'static {
#[doc(alias = "gdk_texture_download")]
fn download(&self, data: &mut [u8], stride: usize);
}
impl<O: IsA<Texture>> TextureExtManual for O {
fn download(&self, data: &mut [u8], stride: usize) {
unsafe {
assert!(
stride >= 4,
"Stride for a CAIRO_FORMAT_ARGB32 should be >= 4"
);
assert!(
stride as i32 >= self.as_ref().width() * 4,
"The stride must be >= 4*width"
);
assert!(
data.len() as i32 >= stride as i32 * self.as_ref().height(),
"The data is not big enough to download the texture"
);
ffi::gdk_texture_download(self.as_ref().to_glib_none().0, data.as_mut_ptr(), stride);
}
}
}