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::{ffi, MemoryFormat, Paintable, Texture};
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 /// Creates a new texture for a blob of image data.
24 ///
25 /// The `GBytes` must contain @stride × @height pixels
26 /// in the given format.
27 /// ## `width`
28 /// the width of the texture
29 /// ## `height`
30 /// the height of the texture
31 /// ## `format`
32 /// the format of the data
33 /// ## `bytes`
34 /// the `GBytes` containing the pixel data
35 /// ## `stride`
36 /// rowstride for the data
37 ///
38 /// # Returns
39 ///
40 /// A newly-created [`Texture`][crate::Texture]
41 #[doc(alias = "gdk_memory_texture_new")]
42 pub fn new(
43 width: i32,
44 height: i32,
45 format: MemoryFormat,
46 bytes: &glib::Bytes,
47 stride: usize,
48 ) -> MemoryTexture {
49 assert_initialized_main_thread!();
50 unsafe {
51 from_glib_full(ffi::gdk_memory_texture_new(
52 width,
53 height,
54 format.into_glib(),
55 bytes.to_glib_none().0,
56 stride,
57 ))
58 }
59 }
60}
61
62unsafe impl Send for MemoryTexture {}
63unsafe impl Sync for MemoryTexture {}