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 
5 use crate::Colorspace;
6 use crate::InterpType;
7 use crate::PixbufFormat;
8 use crate::PixbufRotation;
9 use glib::object::IsA;
10 use glib::object::ObjectType as ObjectType_;
11 use glib::translate::*;
12 use glib::StaticType;
13 use std::fmt;
14 use std::ptr;
15 
16 glib::wrapper! {
17     #[doc(alias = "GdkPixbuf")]
18     pub struct Pixbuf(Object<ffi::GdkPixbuf>) @implements gio::Icon, gio::LoadableIcon;
19 
20     match fn {
21         type_ => || ffi::gdk_pixbuf_get_type(),
22     }
23 }
24 
25 impl Pixbuf {
26     #[doc(alias = "gdk_pixbuf_new")]
new( colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, ) -> Option<Pixbuf>27     pub fn new(
28         colorspace: Colorspace,
29         has_alpha: bool,
30         bits_per_sample: i32,
31         width: i32,
32         height: i32,
33     ) -> Option<Pixbuf> {
34         unsafe {
35             from_glib_full(ffi::gdk_pixbuf_new(
36                 colorspace.into_glib(),
37                 has_alpha.into_glib(),
38                 bits_per_sample,
39                 width,
40                 height,
41             ))
42         }
43     }
44 
45     #[doc(alias = "gdk_pixbuf_new_from_bytes")]
46     #[doc(alias = "new_from_bytes")]
from_bytes( data: &glib::Bytes, colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, rowstride: i32, ) -> Pixbuf47     pub fn from_bytes(
48         data: &glib::Bytes,
49         colorspace: Colorspace,
50         has_alpha: bool,
51         bits_per_sample: i32,
52         width: i32,
53         height: i32,
54         rowstride: i32,
55     ) -> Pixbuf {
56         unsafe {
57             from_glib_full(ffi::gdk_pixbuf_new_from_bytes(
58                 data.to_glib_none().0,
59                 colorspace.into_glib(),
60                 has_alpha.into_glib(),
61                 bits_per_sample,
62                 width,
63                 height,
64                 rowstride,
65             ))
66         }
67     }
68 
69     //#[doc(alias = "gdk_pixbuf_new_from_data")]
70     //#[doc(alias = "new_from_data")]
71     //pub fn from_data(data: &[u8], colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, rowstride: i32, destroy_fn: Option<Box_<dyn FnOnce(&Vec<u8>) + 'static>>) -> Pixbuf {
72     //    unsafe { TODO: call ffi:gdk_pixbuf_new_from_data() }
73     //}
74 
75     #[doc(alias = "gdk_pixbuf_new_from_resource")]
76     #[doc(alias = "new_from_resource")]
from_resource(resource_path: &str) -> Result<Pixbuf, glib::Error>77     pub fn from_resource(resource_path: &str) -> Result<Pixbuf, glib::Error> {
78         unsafe {
79             let mut error = ptr::null_mut();
80             let ret = ffi::gdk_pixbuf_new_from_resource(resource_path.to_glib_none().0, &mut error);
81             if error.is_null() {
82                 Ok(from_glib_full(ret))
83             } else {
84                 Err(from_glib_full(error))
85             }
86         }
87     }
88 
89     #[doc(alias = "gdk_pixbuf_new_from_resource_at_scale")]
90     #[doc(alias = "new_from_resource_at_scale")]
from_resource_at_scale( resource_path: &str, width: i32, height: i32, preserve_aspect_ratio: bool, ) -> Result<Pixbuf, glib::Error>91     pub fn from_resource_at_scale(
92         resource_path: &str,
93         width: i32,
94         height: i32,
95         preserve_aspect_ratio: bool,
96     ) -> Result<Pixbuf, glib::Error> {
97         unsafe {
98             let mut error = ptr::null_mut();
99             let ret = ffi::gdk_pixbuf_new_from_resource_at_scale(
100                 resource_path.to_glib_none().0,
101                 width,
102                 height,
103                 preserve_aspect_ratio.into_glib(),
104                 &mut error,
105             );
106             if error.is_null() {
107                 Ok(from_glib_full(ret))
108             } else {
109                 Err(from_glib_full(error))
110             }
111         }
112     }
113 
114     #[doc(alias = "gdk_pixbuf_new_from_stream")]
115     #[doc(alias = "new_from_stream")]
from_stream<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>( stream: &P, cancellable: Option<&Q>, ) -> Result<Pixbuf, glib::Error>116     pub fn from_stream<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
117         stream: &P,
118         cancellable: Option<&Q>,
119     ) -> Result<Pixbuf, glib::Error> {
120         unsafe {
121             let mut error = ptr::null_mut();
122             let ret = ffi::gdk_pixbuf_new_from_stream(
123                 stream.as_ref().to_glib_none().0,
124                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
125                 &mut error,
126             );
127             if error.is_null() {
128                 Ok(from_glib_full(ret))
129             } else {
130                 Err(from_glib_full(error))
131             }
132         }
133     }
134 
135     #[doc(alias = "gdk_pixbuf_new_from_stream_at_scale")]
136     #[doc(alias = "new_from_stream_at_scale")]
from_stream_at_scale<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>( stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Option<&Q>, ) -> Result<Pixbuf, glib::Error>137     pub fn from_stream_at_scale<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
138         stream: &P,
139         width: i32,
140         height: i32,
141         preserve_aspect_ratio: bool,
142         cancellable: Option<&Q>,
143     ) -> Result<Pixbuf, glib::Error> {
144         unsafe {
145             let mut error = ptr::null_mut();
146             let ret = ffi::gdk_pixbuf_new_from_stream_at_scale(
147                 stream.as_ref().to_glib_none().0,
148                 width,
149                 height,
150                 preserve_aspect_ratio.into_glib(),
151                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
152                 &mut error,
153             );
154             if error.is_null() {
155                 Ok(from_glib_full(ret))
156             } else {
157                 Err(from_glib_full(error))
158             }
159         }
160     }
161 
162     #[doc(alias = "gdk_pixbuf_new_from_xpm_data")]
163     #[doc(alias = "new_from_xpm_data")]
from_xpm_data(data: &[&str]) -> Pixbuf164     pub fn from_xpm_data(data: &[&str]) -> Pixbuf {
165         unsafe { from_glib_full(ffi::gdk_pixbuf_new_from_xpm_data(data.to_glib_none().0)) }
166     }
167 
168     #[doc(alias = "gdk_pixbuf_add_alpha")]
add_alpha(&self, substitute_color: bool, r: u8, g: u8, b: u8) -> Option<Pixbuf>169     pub fn add_alpha(&self, substitute_color: bool, r: u8, g: u8, b: u8) -> Option<Pixbuf> {
170         unsafe {
171             from_glib_full(ffi::gdk_pixbuf_add_alpha(
172                 self.to_glib_none().0,
173                 substitute_color.into_glib(),
174                 r,
175                 g,
176                 b,
177             ))
178         }
179     }
180 
181     #[doc(alias = "gdk_pixbuf_apply_embedded_orientation")]
apply_embedded_orientation(&self) -> Option<Pixbuf>182     pub fn apply_embedded_orientation(&self) -> Option<Pixbuf> {
183         unsafe {
184             from_glib_full(ffi::gdk_pixbuf_apply_embedded_orientation(
185                 self.to_glib_none().0,
186             ))
187         }
188     }
189 
190     #[doc(alias = "gdk_pixbuf_composite")]
composite( &self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType, overall_alpha: i32, )191     pub fn composite(
192         &self,
193         dest: &Pixbuf,
194         dest_x: i32,
195         dest_y: i32,
196         dest_width: i32,
197         dest_height: i32,
198         offset_x: f64,
199         offset_y: f64,
200         scale_x: f64,
201         scale_y: f64,
202         interp_type: InterpType,
203         overall_alpha: i32,
204     ) {
205         unsafe {
206             ffi::gdk_pixbuf_composite(
207                 self.to_glib_none().0,
208                 dest.to_glib_none().0,
209                 dest_x,
210                 dest_y,
211                 dest_width,
212                 dest_height,
213                 offset_x,
214                 offset_y,
215                 scale_x,
216                 scale_y,
217                 interp_type.into_glib(),
218                 overall_alpha,
219             );
220         }
221     }
222 
223     #[doc(alias = "gdk_pixbuf_composite_color")]
composite_color( &self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType, overall_alpha: i32, check_x: i32, check_y: i32, check_size: i32, color1: u32, color2: u32, )224     pub fn composite_color(
225         &self,
226         dest: &Pixbuf,
227         dest_x: i32,
228         dest_y: i32,
229         dest_width: i32,
230         dest_height: i32,
231         offset_x: f64,
232         offset_y: f64,
233         scale_x: f64,
234         scale_y: f64,
235         interp_type: InterpType,
236         overall_alpha: i32,
237         check_x: i32,
238         check_y: i32,
239         check_size: i32,
240         color1: u32,
241         color2: u32,
242     ) {
243         unsafe {
244             ffi::gdk_pixbuf_composite_color(
245                 self.to_glib_none().0,
246                 dest.to_glib_none().0,
247                 dest_x,
248                 dest_y,
249                 dest_width,
250                 dest_height,
251                 offset_x,
252                 offset_y,
253                 scale_x,
254                 scale_y,
255                 interp_type.into_glib(),
256                 overall_alpha,
257                 check_x,
258                 check_y,
259                 check_size,
260                 color1,
261                 color2,
262             );
263         }
264     }
265 
266     #[doc(alias = "gdk_pixbuf_composite_color_simple")]
composite_color_simple( &self, dest_width: i32, dest_height: i32, interp_type: InterpType, overall_alpha: i32, check_size: i32, color1: u32, color2: u32, ) -> Option<Pixbuf>267     pub fn composite_color_simple(
268         &self,
269         dest_width: i32,
270         dest_height: i32,
271         interp_type: InterpType,
272         overall_alpha: i32,
273         check_size: i32,
274         color1: u32,
275         color2: u32,
276     ) -> Option<Pixbuf> {
277         unsafe {
278             from_glib_full(ffi::gdk_pixbuf_composite_color_simple(
279                 self.to_glib_none().0,
280                 dest_width,
281                 dest_height,
282                 interp_type.into_glib(),
283                 overall_alpha,
284                 check_size,
285                 color1,
286                 color2,
287             ))
288         }
289     }
290 
291     #[doc(alias = "gdk_pixbuf_copy")]
copy(&self) -> Option<Pixbuf>292     pub fn copy(&self) -> Option<Pixbuf> {
293         unsafe { from_glib_full(ffi::gdk_pixbuf_copy(self.to_glib_none().0)) }
294     }
295 
296     #[doc(alias = "gdk_pixbuf_copy_area")]
copy_area( &self, src_x: i32, src_y: i32, width: i32, height: i32, dest_pixbuf: &Pixbuf, dest_x: i32, dest_y: i32, )297     pub fn copy_area(
298         &self,
299         src_x: i32,
300         src_y: i32,
301         width: i32,
302         height: i32,
303         dest_pixbuf: &Pixbuf,
304         dest_x: i32,
305         dest_y: i32,
306     ) {
307         unsafe {
308             ffi::gdk_pixbuf_copy_area(
309                 self.to_glib_none().0,
310                 src_x,
311                 src_y,
312                 width,
313                 height,
314                 dest_pixbuf.to_glib_none().0,
315                 dest_x,
316                 dest_y,
317             );
318         }
319     }
320 
321     #[cfg(any(feature = "v2_36", feature = "dox"))]
322     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
323     #[doc(alias = "gdk_pixbuf_copy_options")]
copy_options(&self, dest_pixbuf: &Pixbuf) -> bool324     pub fn copy_options(&self, dest_pixbuf: &Pixbuf) -> bool {
325         unsafe {
326             from_glib(ffi::gdk_pixbuf_copy_options(
327                 self.to_glib_none().0,
328                 dest_pixbuf.to_glib_none().0,
329             ))
330         }
331     }
332 
333     #[doc(alias = "gdk_pixbuf_fill")]
fill(&self, pixel: u32)334     pub fn fill(&self, pixel: u32) {
335         unsafe {
336             ffi::gdk_pixbuf_fill(self.to_glib_none().0, pixel);
337         }
338     }
339 
340     #[doc(alias = "gdk_pixbuf_flip")]
flip(&self, horizontal: bool) -> Option<Pixbuf>341     pub fn flip(&self, horizontal: bool) -> Option<Pixbuf> {
342         unsafe {
343             from_glib_full(ffi::gdk_pixbuf_flip(
344                 self.to_glib_none().0,
345                 horizontal.into_glib(),
346             ))
347         }
348     }
349 
350     #[doc(alias = "gdk_pixbuf_get_bits_per_sample")]
351     #[doc(alias = "get_bits_per_sample")]
bits_per_sample(&self) -> i32352     pub fn bits_per_sample(&self) -> i32 {
353         unsafe { ffi::gdk_pixbuf_get_bits_per_sample(self.to_glib_none().0) }
354     }
355 
356     #[doc(alias = "gdk_pixbuf_get_byte_length")]
357     #[doc(alias = "get_byte_length")]
byte_length(&self) -> usize358     pub fn byte_length(&self) -> usize {
359         unsafe { ffi::gdk_pixbuf_get_byte_length(self.to_glib_none().0) }
360     }
361 
362     #[doc(alias = "gdk_pixbuf_get_colorspace")]
363     #[doc(alias = "get_colorspace")]
colorspace(&self) -> Colorspace364     pub fn colorspace(&self) -> Colorspace {
365         unsafe { from_glib(ffi::gdk_pixbuf_get_colorspace(self.to_glib_none().0)) }
366     }
367 
368     #[doc(alias = "gdk_pixbuf_get_has_alpha")]
369     #[doc(alias = "get_has_alpha")]
has_alpha(&self) -> bool370     pub fn has_alpha(&self) -> bool {
371         unsafe { from_glib(ffi::gdk_pixbuf_get_has_alpha(self.to_glib_none().0)) }
372     }
373 
374     #[doc(alias = "gdk_pixbuf_get_height")]
375     #[doc(alias = "get_height")]
height(&self) -> i32376     pub fn height(&self) -> i32 {
377         unsafe { ffi::gdk_pixbuf_get_height(self.to_glib_none().0) }
378     }
379 
380     #[doc(alias = "gdk_pixbuf_get_n_channels")]
381     #[doc(alias = "get_n_channels")]
n_channels(&self) -> i32382     pub fn n_channels(&self) -> i32 {
383         unsafe { ffi::gdk_pixbuf_get_n_channels(self.to_glib_none().0) }
384     }
385 
386     #[doc(alias = "gdk_pixbuf_get_option")]
387     #[doc(alias = "get_option")]
option(&self, key: &str) -> Option<glib::GString>388     pub fn option(&self, key: &str) -> Option<glib::GString> {
389         unsafe {
390             from_glib_none(ffi::gdk_pixbuf_get_option(
391                 self.to_glib_none().0,
392                 key.to_glib_none().0,
393             ))
394         }
395     }
396 
397     //#[doc(alias = "gdk_pixbuf_get_options")]
398     //#[doc(alias = "get_options")]
399     //pub fn options(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 } {
400     //    unsafe { TODO: call ffi:gdk_pixbuf_get_options() }
401     //}
402 
403     #[doc(alias = "gdk_pixbuf_get_rowstride")]
404     #[doc(alias = "get_rowstride")]
rowstride(&self) -> i32405     pub fn rowstride(&self) -> i32 {
406         unsafe { ffi::gdk_pixbuf_get_rowstride(self.to_glib_none().0) }
407     }
408 
409     #[doc(alias = "gdk_pixbuf_get_width")]
410     #[doc(alias = "get_width")]
width(&self) -> i32411     pub fn width(&self) -> i32 {
412         unsafe { ffi::gdk_pixbuf_get_width(self.to_glib_none().0) }
413     }
414 
415     #[doc(alias = "gdk_pixbuf_new_subpixbuf")]
new_subpixbuf(&self, src_x: i32, src_y: i32, width: i32, height: i32) -> Option<Pixbuf>416     pub fn new_subpixbuf(&self, src_x: i32, src_y: i32, width: i32, height: i32) -> Option<Pixbuf> {
417         unsafe {
418             from_glib_full(ffi::gdk_pixbuf_new_subpixbuf(
419                 self.to_glib_none().0,
420                 src_x,
421                 src_y,
422                 width,
423                 height,
424             ))
425         }
426     }
427 
428     #[doc(alias = "gdk_pixbuf_read_pixel_bytes")]
read_pixel_bytes(&self) -> Option<glib::Bytes>429     pub fn read_pixel_bytes(&self) -> Option<glib::Bytes> {
430         unsafe { from_glib_full(ffi::gdk_pixbuf_read_pixel_bytes(self.to_glib_none().0)) }
431     }
432 
433     #[cfg(any(feature = "v2_36", feature = "dox"))]
434     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
435     #[doc(alias = "gdk_pixbuf_remove_option")]
remove_option(&self, key: &str) -> bool436     pub fn remove_option(&self, key: &str) -> bool {
437         unsafe {
438             from_glib(ffi::gdk_pixbuf_remove_option(
439                 self.to_glib_none().0,
440                 key.to_glib_none().0,
441             ))
442         }
443     }
444 
445     #[doc(alias = "gdk_pixbuf_rotate_simple")]
rotate_simple(&self, angle: PixbufRotation) -> Option<Pixbuf>446     pub fn rotate_simple(&self, angle: PixbufRotation) -> Option<Pixbuf> {
447         unsafe {
448             from_glib_full(ffi::gdk_pixbuf_rotate_simple(
449                 self.to_glib_none().0,
450                 angle.into_glib(),
451             ))
452         }
453     }
454 
455     #[doc(alias = "gdk_pixbuf_saturate_and_pixelate")]
saturate_and_pixelate(&self, dest: &Pixbuf, saturation: f32, pixelate: bool)456     pub fn saturate_and_pixelate(&self, dest: &Pixbuf, saturation: f32, pixelate: bool) {
457         unsafe {
458             ffi::gdk_pixbuf_saturate_and_pixelate(
459                 self.to_glib_none().0,
460                 dest.to_glib_none().0,
461                 saturation,
462                 pixelate.into_glib(),
463             );
464         }
465     }
466 
467     //#[doc(alias = "gdk_pixbuf_save")]
468     //pub fn save<P: AsRef<std::path::Path>>(&self, filename: P, type_: &str, error: Option<&mut glib::Error>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool {
469     //    unsafe { TODO: call ffi:gdk_pixbuf_save() }
470     //}
471 
472     //#[doc(alias = "gdk_pixbuf_save_to_buffer")]
473     //pub fn save_to_buffer(&self, type_: &str, error: Option<&mut glib::Error>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<Vec<u8>> {
474     //    unsafe { TODO: call ffi:gdk_pixbuf_save_to_buffer() }
475     //}
476 
477     //#[doc(alias = "gdk_pixbuf_save_to_callback")]
478     //pub fn save_to_callback<P: FnMut(&Vec<u8>, usize, &glib::Error) -> bool>(&self, save_func: P, type_: &str, error: Option<&mut glib::Error>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool {
479     //    unsafe { TODO: call ffi:gdk_pixbuf_save_to_callback() }
480     //}
481 
482     //#[doc(alias = "gdk_pixbuf_save_to_callbackv")]
483     //pub fn save_to_callbackv<P: FnMut(&Vec<u8>, usize, &glib::Error) -> bool>(&self, save_func: P, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result<(), glib::Error> {
484     //    unsafe { TODO: call ffi:gdk_pixbuf_save_to_callbackv() }
485     //}
486 
487     //#[doc(alias = "gdk_pixbuf_save_to_stream")]
488     //pub fn save_to_stream<P: IsA<gio::OutputStream>, Q: IsA<gio::Cancellable>>(&self, stream: &P, type_: &str, cancellable: Option<&Q>, error: Option<&mut glib::Error>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool {
489     //    unsafe { TODO: call ffi:gdk_pixbuf_save_to_stream() }
490     //}
491 
492     //#[doc(alias = "gdk_pixbuf_save_to_stream_async")]
493     //pub fn save_to_stream_async<P: IsA<gio::OutputStream>, Q: IsA<gio::Cancellable>, R: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, stream: &P, type_: &str, cancellable: Option<&Q>, callback: R, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
494     //    unsafe { TODO: call ffi:gdk_pixbuf_save_to_stream_async() }
495     //}
496 
497     //
498     //pub fn save_to_stream_async_future<P: IsA<gio::OutputStream> + Clone + 'static>(&self, stream: &P, type_: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
499 
500     //let stream = stream.clone();
501     //let type_ = String::from(type_);
502     //Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
503     //    obj.save_to_stream_async(
504     //        &stream,
505     //        &type_,
506     //        Some(cancellable),
507     //        ,
508     //        move |res| {
509     //            send.resolve(res);
510     //        },
511     //    );
512     //}))
513     //}
514 
515     #[doc(alias = "gdk_pixbuf_scale")]
scale( &self, dest: &Pixbuf, dest_x: i32, dest_y: i32, dest_width: i32, dest_height: i32, offset_x: f64, offset_y: f64, scale_x: f64, scale_y: f64, interp_type: InterpType, )516     pub fn scale(
517         &self,
518         dest: &Pixbuf,
519         dest_x: i32,
520         dest_y: i32,
521         dest_width: i32,
522         dest_height: i32,
523         offset_x: f64,
524         offset_y: f64,
525         scale_x: f64,
526         scale_y: f64,
527         interp_type: InterpType,
528     ) {
529         unsafe {
530             ffi::gdk_pixbuf_scale(
531                 self.to_glib_none().0,
532                 dest.to_glib_none().0,
533                 dest_x,
534                 dest_y,
535                 dest_width,
536                 dest_height,
537                 offset_x,
538                 offset_y,
539                 scale_x,
540                 scale_y,
541                 interp_type.into_glib(),
542             );
543         }
544     }
545 
546     #[doc(alias = "gdk_pixbuf_scale_simple")]
scale_simple( &self, dest_width: i32, dest_height: i32, interp_type: InterpType, ) -> Option<Pixbuf>547     pub fn scale_simple(
548         &self,
549         dest_width: i32,
550         dest_height: i32,
551         interp_type: InterpType,
552     ) -> Option<Pixbuf> {
553         unsafe {
554             from_glib_full(ffi::gdk_pixbuf_scale_simple(
555                 self.to_glib_none().0,
556                 dest_width,
557                 dest_height,
558                 interp_type.into_glib(),
559             ))
560         }
561     }
562 
563     #[doc(alias = "gdk_pixbuf_set_option")]
set_option(&self, key: &str, value: &str) -> bool564     pub fn set_option(&self, key: &str, value: &str) -> bool {
565         unsafe {
566             from_glib(ffi::gdk_pixbuf_set_option(
567                 self.to_glib_none().0,
568                 key.to_glib_none().0,
569                 value.to_glib_none().0,
570             ))
571         }
572     }
573 
574     #[doc(alias = "pixel-bytes")]
pixel_bytes(&self) -> Option<glib::Bytes>575     pub fn pixel_bytes(&self) -> Option<glib::Bytes> {
576         unsafe {
577             let mut value = glib::Value::from_type(<glib::Bytes as StaticType>::static_type());
578             glib::gobject_ffi::g_object_get_property(
579                 self.as_ptr() as *mut glib::gobject_ffi::GObject,
580                 b"pixel-bytes\0".as_ptr() as *const _,
581                 value.to_glib_none_mut().0,
582             );
583             value
584                 .get()
585                 .expect("Return Value for property `pixel-bytes` getter")
586         }
587     }
588 
589     #[cfg(any(feature = "v2_36_8", feature = "dox"))]
590     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36_8")))]
591     #[doc(alias = "gdk_pixbuf_calculate_rowstride")]
calculate_rowstride( colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, ) -> i32592     pub fn calculate_rowstride(
593         colorspace: Colorspace,
594         has_alpha: bool,
595         bits_per_sample: i32,
596         width: i32,
597         height: i32,
598     ) -> i32 {
599         unsafe {
600             ffi::gdk_pixbuf_calculate_rowstride(
601                 colorspace.into_glib(),
602                 has_alpha.into_glib(),
603                 bits_per_sample,
604                 width,
605                 height,
606             )
607         }
608     }
609 
610     #[doc(alias = "gdk_pixbuf_get_formats")]
611     #[doc(alias = "get_formats")]
formats() -> Vec<PixbufFormat>612     pub fn formats() -> Vec<PixbufFormat> {
613         unsafe { FromGlibPtrContainer::from_glib_container(ffi::gdk_pixbuf_get_formats()) }
614     }
615 
616     #[cfg(any(feature = "v2_40", feature = "dox"))]
617     #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_40")))]
618     #[doc(alias = "gdk_pixbuf_init_modules")]
init_modules(path: &str) -> Result<(), glib::Error>619     pub fn init_modules(path: &str) -> Result<(), glib::Error> {
620         unsafe {
621             let mut error = ptr::null_mut();
622             let _ = ffi::gdk_pixbuf_init_modules(path.to_glib_none().0, &mut error);
623             if error.is_null() {
624                 Ok(())
625             } else {
626                 Err(from_glib_full(error))
627             }
628         }
629     }
630 }
631 
632 impl fmt::Display for Pixbuf {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result633     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
634         f.write_str("Pixbuf")
635     }
636 }
637