Skip to main content

gdk4/auto/
memory_texture.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{MemoryFormat, Paintable, Texture, ffi};
6use glib::translate::*;
7
8glib::wrapper! {
9    /// A [`Texture`][crate::Texture] representing image data in memory.
10    ///
11    /// # Implements
12    ///
13    /// [`TextureExt`][trait@crate::prelude::TextureExt], [`PaintableExt`][trait@crate::prelude::PaintableExt], [`trait@gio::prelude::IconExt`], [`trait@gio::prelude::LoadableIconExt`], [`TextureExtManual`][trait@crate::prelude::TextureExtManual]
14    #[doc(alias = "GdkMemoryTexture")]
15    pub struct MemoryTexture(Object<ffi::GdkMemoryTexture, ffi::GdkMemoryTextureClass>) @extends Texture, @implements Paintable, gio::Icon, gio::LoadableIcon;
16
17    match fn {
18        type_ => || ffi::gdk_memory_texture_get_type(),
19    }
20}
21
22impl MemoryTexture {
23    ///  @height pixels
24    /// in the given format.
25    /// ## `width`
26    /// the width of the texture
27    /// ## `height`
28    /// the height of the texture
29    /// ## `format`
30    /// the format of the data
31    /// ## `bytes`
32    /// the `GBytes` containing the pixel data
33    /// ## `stride`
34    /// rowstride for the data
35    ///
36    /// # Returns
37    ///
38    /// A newly-created [`Texture`][crate::Texture]
39    #[doc(alias = "gdk_memory_texture_new")]
40    pub fn new(
41        width: i32,
42        height: i32,
43        format: MemoryFormat,
44        bytes: &glib::Bytes,
45        stride: usize,
46    ) -> MemoryTexture {
47        assert_initialized_main_thread!();
48        unsafe {
49            from_glib_full(ffi::gdk_memory_texture_new(
50                width,
51                height,
52                format.into_glib(),
53                bytes.to_glib_none().0,
54                stride,
55            ))
56        }
57    }
58}
59
60unsafe impl Send for MemoryTexture {}
61unsafe impl Sync for MemoryTexture {}