gdk-pixbuf-0.20.9/.cargo_vcs_info.json0000644000000001500000000000100131600ustar { "git": { "sha1": "052084edb141065138e407dd6e53471ad166413f" }, "path_in_vcs": "gdk-pixbuf" }gdk-pixbuf-0.20.9/COPYRIGHT000064400000000000000000000012131046102023000132440ustar 00000000000000The gtk-rs Project is licensed under the MIT license, see the LICENSE file or . Copyrights in the gtk-rs Project project are retained by their contributors. No copyright assignment is required to contribute to the gtk-rs Project project. For full authorship information, see the version control history. This project provides interoperability with various GNOME libraries but doesn't distribute any parts of them. Distributing compiled libraries and executables that link to those libraries may be subject to terms of the GNU LGPL or other licenses. For more information check the license of each GNOME library. gdk-pixbuf-0.20.9/Cargo.lock0000644000000310050000000000100111360ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "autocfg" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "cfg-expr" version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d4ba6e40bd1184518716a6e1a781bf9160e286d219ccdb8ab2612e74cfe4789" dependencies = [ "smallvec", "target-lexicon", ] [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "futures-channel" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", ] [[package]] name = "futures-core" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", "futures-util", ] [[package]] name = "futures-io" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "futures-task" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-macro", "futures-task", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "gdk-pixbuf" version = "0.20.9" dependencies = [ "gdk-pixbuf-sys", "gio", "gir-format-check", "glib", "libc", ] [[package]] name = "gdk-pixbuf-sys" version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67f2587c9202bf997476bbba6aaed4f78a11538a2567df002a5f57f5331d0b5c" dependencies = [ "gio-sys", "glib-sys", "gobject-sys", "libc", "system-deps", ] [[package]] name = "gio" version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4f00c70f8029d84ea7572dd0e1aaa79e5329667b4c17f329d79ffb1e6277487" dependencies = [ "futures-channel", "futures-core", "futures-io", "futures-util", "gio-sys", "glib", "libc", "pin-project-lite", "smallvec", ] [[package]] name = "gio-sys" version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "160eb5250a26998c3e1b54e6a3d4ea15c6c7762a6062a19a7b63eff6e2b33f9e" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", "windows-sys", ] [[package]] name = "gir-format-check" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a5da913a8586ce748f1164c890e1ebe75a7bbc472668f57b7f9fb893d7ac416" [[package]] name = "glib" version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707b819af8059ee5395a2de9f2317d87a53dbad8846a2f089f0bb44703f37686" dependencies = [ "bitflags", "futures-channel", "futures-core", "futures-executor", "futures-task", "futures-util", "gio-sys", "glib-macros", "glib-sys", "gobject-sys", "libc", "memchr", "smallvec", ] [[package]] name = "glib-macros" version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "715601f8f02e71baef9c1f94a657a9a77c192aea6097cf9ae7e5e177cd8cde68" dependencies = [ "heck", "proc-macro-crate", "proc-macro2", "quote", "syn", ] [[package]] name = "glib-sys" version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8928869a44cfdd1fccb17d6746e4ff82c8f82e41ce705aa026a52ca8dc3aefb" dependencies = [ "libc", "system-deps", ] [[package]] name = "gobject-sys" version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c773a3cb38a419ad9c26c81d177d96b4b08980e8bdbbf32dace883e96e96e7e3" dependencies = [ "glib-sys", "libc", "system-deps", ] [[package]] name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indexmap" version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "libc" version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "pin-project-lite" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "proc-macro-crate" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] [[package]] name = "serde" version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_spanned" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "syn" version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "system-deps" version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66d23aaf9f331227789a99e8de4c91bf46703add012bdfd45fdecdfb2975a005" dependencies = [ "cfg-expr", "heck", "pkg-config", "toml", "version-compare", ] [[package]] name = "target-lexicon" version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "toml" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", "toml_datetime", "toml_edit", ] [[package]] name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", "winnow", ] [[package]] name = "unicode-ident" version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "version-compare" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" dependencies = [ "memchr", ] gdk-pixbuf-0.20.9/Cargo.toml0000644000000032420000000000100111630ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.70" name = "gdk-pixbuf" version = "0.20.9" authors = ["The gtk-rs Project Developers"] build = false exclude = ["gir-files/*"] autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = "Rust bindings for the GdkPixbuf library" homepage = "https://gtk-rs.org/" documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gdk_pixbuf/" readme = "README.md" keywords = [ "gdk-pixbuf", "gtk-rs", "gnome", ] license = "MIT" repository = "https://github.com/gtk-rs/gtk-rs-core" [package.metadata.docs.rs] all-features = true rustc-args = [ "--cfg", "docsrs", ] rustdoc-args = [ "--cfg", "docsrs", "--generate-link-to-definition", ] [lib] name = "gdk_pixbuf" path = "src/lib.rs" [[test]] name = "check_gir" path = "tests/check_gir.rs" [[test]] name = "overflow" path = "tests/overflow.rs" [dependencies.gdk-pixbuf-sys] version = "0.20" [dependencies.gio] version = "0.20" [dependencies.glib] version = "0.20.3" [dependencies.libc] version = "0.2" [dev-dependencies.gir-format-check] version = "^0.1" [features] v2_40 = ["gdk-pixbuf-sys/v2_40"] v2_42 = [ "v2_40", "gdk-pixbuf-sys/v2_42", ] gdk-pixbuf-0.20.9/Cargo.toml.orig000064400000000000000000000015471046102023000146520ustar 00000000000000[package] name = "gdk-pixbuf" keywords = ["gdk-pixbuf", "gtk-rs", "gnome"] readme = "README.md" documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gdk_pixbuf/" description = "Rust bindings for the GdkPixbuf library" authors.workspace = true edition.workspace = true exclude.workspace = true homepage.workspace = true license.workspace = true repository.workspace = true rust-version.workspace = true version.workspace = true [lib] name = "gdk_pixbuf" [features] v2_40 = ["gdk-pixbuf-sys/v2_40"] v2_42 = ["v2_40", "gdk-pixbuf-sys/v2_42"] [dependencies] gdk-pixbuf-sys.workspace = true libc.workspace = true glib.workspace = true gio.workspace = true [dev-dependencies] gir-format-check.workspace = true [package.metadata.docs.rs] all-features = true rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] gdk-pixbuf-0.20.9/Gir.toml000064400000000000000000000120111046102023000133650ustar 00000000000000[options] girs_directories = ["../gir-files"] library = "GdkPixbuf" version = "2.0" min_cfg_version = "2.36.8" target_path = "." work_mode = "normal" use_gi_docgen = true single_version_file = true deprecate_by_min_version = true trust_return_value_nullability = true generate = [ "GdkPixbuf.Colorspace", "GdkPixbuf.InterpType", "GdkPixbuf.PixbufAlphaMode", "GdkPixbuf.PixbufError", "GdkPixbuf.PixbufFormatFlags", "GdkPixbuf.PixbufLoader", "GdkPixbuf.PixbufNonAnim", "GdkPixbuf.PixbufRotation", "GdkPixbuf.PixbufSimpleAnim", ] manual = [ "GdkPixbuf.PixbufAnimationIter", "Gio.AsyncReadyCallback", "Gio.Cancellable", "Gio.Icon", "Gio.InputStream", "Gio.LoadableIcon", "Gio.OutputStream", "GLib.Bytes", "GLib.Error", ] [[object]] name = "GdkPixbuf.Pixbuf" status = "generate" [[object.function]] name = "get_pixels" #manual array without length manual = true # docs were manually written to include a section on safety generate_doc = false [[object.function]] name = "get_pixels_with_length" #manual as get_pixels ignore = true [[object.function]] name = "read_pixels" #unimplementable, use get_pixels instead ignore = true [[object.function]] name = "new_from_file" [object.function.return] nullable = false [[object.function]] name = "new" [object.function.return] nullable = true [[object.function]] name = "new_from_file_at_size" [object.function.return] nullable = false [[object.function]] name = "new_from_file_at_scale" [object.function.return] nullable = false [[object.function]] name = "new_from_stream_async" # wrong async return manual = true [[object.function]] name = "new_from_stream_at_scale_async" # wrong return and don't generated manual = true [[object.function]] name = "get_file_info" # wrong return manual = true [[object.function]] name = "get_file_info_async" # wrong async return manual = true [[object.function]] name = "save_to_bufferv" # manual complex param manual = true [[object.function]] name = "save_to_streamv" # manual complex param manual = true [[object.function]] name = "savev" # manual complex param manual = true [[object.function]] name = "save_to_streamv_async" # manual complex param manual = true [[object.function]] name = "new_from_resource" [object.function.return] # see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108 nullable = false [[object.function]] name = "new_from_resource_at_scale" [object.function.return] # see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108 nullable = false [[object.function]] name = "new_from_stream" [object.function.return] # see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108 nullable = false [[object.function]] name = "new_from_stream_at_scale" [object.function.return] # see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108 nullable = false [[object.function]] name = "new_from_xpm_data" [object.function.return] nullable_return_is_error = "Invalid XPM data" [[object.function]] name = "add_alpha" [object.function.return] nullable_return_is_error = "Failed to add alpha channel" [[object]] name = "GdkPixbuf.PixbufAnimation" status = "generate" manual_traits = ["PixbufAnimationExtManual"] [[object.function]] name = "get_iter" # TimeVal misses memory management functions manual = true [[object.function]] name = "new_from_stream_async" constructor = true [object.function.return] # see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108 nullable = false [[object.function]] name = "new_from_file" [object.function.return] # see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108 nullable = false [[object.function]] name = "new_from_resource" [object.function.return] # see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108 nullable = false [[object.function]] name = "new_from_stream" [object.function.return] # see https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/105#note_1277108 nullable = false [[object.function]] name = "get_static_image" [object.function.return] nullable = true [[object]] name = "GdkPixbuf.PixbufFormat" status = "generate" concurrency = "send+sync" [[object.function]] pattern = "get_.+" [[object.function.parameter]] name = "format" const = true [[object.function]] pattern = "is_.+" [[object.function.parameter]] name = "format" const = true gdk-pixbuf-0.20.9/LICENSE000064400000000000000000000020001046102023000127510ustar 00000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gdk-pixbuf-0.20.9/README.md000064400000000000000000000025631046102023000132410ustar 00000000000000# Rust GDK-PixBuf bindings __Rust__ bindings and wrappers for [GDK-Pixbuf](https://docs.gtk.org/gdk-pixbuf), part of [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core). GDK-PixBuf __2.36.8__ is the lowest supported version for the underlying library. ## Minimum supported Rust version Currently, the minimum supported Rust version is `1.70.0`. ## Documentation * [Rust API - Stable](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gdk_pixbuf/) * [Rust API - Development](https://gtk-rs.org/gtk-rs-core/git/docs/gdk_pixbuf) * [C API](https://developer.gnome.org/gdk-pixbuf/stable/) * [GTK Installation instructions](https://www.gtk.org/docs/installations/) ## Using We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), as [demonstrated here](https://gtk-rs.org/#using). If you want to track the bleeding edge, use the git dependency instead: ```toml [dependencies] gdk-pixbuf = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gdk-pixbuf" } ``` Avoid mixing versioned and git crates like this: ```toml # This will not compile [dependencies] gdk-pixbuf = "0.13" gdk-pixbuf = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gdk-pixbuf" } ``` ### See Also * [glib](https://crates.io/crates/glib) * [gio](https://crates.io/crates/gio) ## License __gdk-pixbuf__ is available under the MIT License, please refer to it. gdk-pixbuf-0.20.9/src/auto/enums.rs000064400000000000000000000343071046102023000152170ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::ffi; use glib::{prelude::*, translate::*}; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GdkColorspace")] pub enum Colorspace { #[doc(alias = "GDK_COLORSPACE_RGB")] Rgb, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for Colorspace { type GlibType = ffi::GdkColorspace; #[inline] fn into_glib(self) -> ffi::GdkColorspace { match self { Self::Rgb => ffi::GDK_COLORSPACE_RGB, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for Colorspace { #[inline] unsafe fn from_glib(value: ffi::GdkColorspace) -> Self { match value { ffi::GDK_COLORSPACE_RGB => Self::Rgb, value => Self::__Unknown(value), } } } impl StaticType for Colorspace { #[inline] #[doc(alias = "gdk_colorspace_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::gdk_colorspace_get_type()) } } } impl glib::HasParamSpec for Colorspace { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for Colorspace { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for Colorspace { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for Colorspace { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: Colorspace) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GdkInterpType")] pub enum InterpType { #[doc(alias = "GDK_INTERP_NEAREST")] Nearest, #[doc(alias = "GDK_INTERP_TILES")] Tiles, #[doc(alias = "GDK_INTERP_BILINEAR")] Bilinear, #[doc(alias = "GDK_INTERP_HYPER")] Hyper, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for InterpType { type GlibType = ffi::GdkInterpType; #[inline] fn into_glib(self) -> ffi::GdkInterpType { match self { Self::Nearest => ffi::GDK_INTERP_NEAREST, Self::Tiles => ffi::GDK_INTERP_TILES, Self::Bilinear => ffi::GDK_INTERP_BILINEAR, Self::Hyper => ffi::GDK_INTERP_HYPER, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for InterpType { #[inline] unsafe fn from_glib(value: ffi::GdkInterpType) -> Self { match value { ffi::GDK_INTERP_NEAREST => Self::Nearest, ffi::GDK_INTERP_TILES => Self::Tiles, ffi::GDK_INTERP_BILINEAR => Self::Bilinear, ffi::GDK_INTERP_HYPER => Self::Hyper, value => Self::__Unknown(value), } } } impl StaticType for InterpType { #[inline] #[doc(alias = "gdk_interp_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::gdk_interp_type_get_type()) } } } impl glib::HasParamSpec for InterpType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for InterpType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for InterpType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for InterpType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: InterpType) -> Self { ToValue::to_value(&v) } } #[cfg_attr(feature = "v2_42", deprecated = "Since 2.42")] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GdkPixbufAlphaMode")] pub enum PixbufAlphaMode { #[doc(alias = "GDK_PIXBUF_ALPHA_BILEVEL")] Bilevel, #[doc(alias = "GDK_PIXBUF_ALPHA_FULL")] Full, #[doc(hidden)] __Unknown(i32), } #[allow(deprecated)] #[doc(hidden)] impl IntoGlib for PixbufAlphaMode { type GlibType = ffi::GdkPixbufAlphaMode; #[inline] fn into_glib(self) -> ffi::GdkPixbufAlphaMode { match self { Self::Bilevel => ffi::GDK_PIXBUF_ALPHA_BILEVEL, Self::Full => ffi::GDK_PIXBUF_ALPHA_FULL, Self::__Unknown(value) => value, } } } #[allow(deprecated)] #[doc(hidden)] impl FromGlib for PixbufAlphaMode { #[inline] unsafe fn from_glib(value: ffi::GdkPixbufAlphaMode) -> Self { match value { ffi::GDK_PIXBUF_ALPHA_BILEVEL => Self::Bilevel, ffi::GDK_PIXBUF_ALPHA_FULL => Self::Full, value => Self::__Unknown(value), } } } #[allow(deprecated)] impl StaticType for PixbufAlphaMode { #[inline] #[doc(alias = "gdk_pixbuf_alpha_mode_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::gdk_pixbuf_alpha_mode_get_type()) } } } #[allow(deprecated)] impl glib::HasParamSpec for PixbufAlphaMode { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[allow(deprecated)] impl glib::value::ValueType for PixbufAlphaMode { type Type = Self; } #[allow(deprecated)] unsafe impl<'a> glib::value::FromValue<'a> for PixbufAlphaMode { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[allow(deprecated)] impl ToValue for PixbufAlphaMode { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[allow(deprecated)] impl From for glib::Value { #[inline] fn from(v: PixbufAlphaMode) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GdkPixbufError")] pub enum PixbufError { #[doc(alias = "GDK_PIXBUF_ERROR_CORRUPT_IMAGE")] CorruptImage, #[doc(alias = "GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY")] InsufficientMemory, #[doc(alias = "GDK_PIXBUF_ERROR_BAD_OPTION")] BadOption, #[doc(alias = "GDK_PIXBUF_ERROR_UNKNOWN_TYPE")] UnknownType, #[doc(alias = "GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION")] UnsupportedOperation, #[doc(alias = "GDK_PIXBUF_ERROR_FAILED")] Failed, #[doc(alias = "GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION")] IncompleteAnimation, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for PixbufError { type GlibType = ffi::GdkPixbufError; #[inline] fn into_glib(self) -> ffi::GdkPixbufError { match self { Self::CorruptImage => ffi::GDK_PIXBUF_ERROR_CORRUPT_IMAGE, Self::InsufficientMemory => ffi::GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, Self::BadOption => ffi::GDK_PIXBUF_ERROR_BAD_OPTION, Self::UnknownType => ffi::GDK_PIXBUF_ERROR_UNKNOWN_TYPE, Self::UnsupportedOperation => ffi::GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION, Self::Failed => ffi::GDK_PIXBUF_ERROR_FAILED, Self::IncompleteAnimation => ffi::GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for PixbufError { #[inline] unsafe fn from_glib(value: ffi::GdkPixbufError) -> Self { match value { ffi::GDK_PIXBUF_ERROR_CORRUPT_IMAGE => Self::CorruptImage, ffi::GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY => Self::InsufficientMemory, ffi::GDK_PIXBUF_ERROR_BAD_OPTION => Self::BadOption, ffi::GDK_PIXBUF_ERROR_UNKNOWN_TYPE => Self::UnknownType, ffi::GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION => Self::UnsupportedOperation, ffi::GDK_PIXBUF_ERROR_FAILED => Self::Failed, ffi::GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION => Self::IncompleteAnimation, value => Self::__Unknown(value), } } } impl glib::error::ErrorDomain for PixbufError { #[inline] fn domain() -> glib::Quark { unsafe { from_glib(ffi::gdk_pixbuf_error_quark()) } } #[inline] fn code(self) -> i32 { self.into_glib() } #[inline] #[allow(clippy::match_single_binding)] fn from(code: i32) -> Option { match unsafe { from_glib(code) } { Self::__Unknown(_) => Some(Self::Failed), value => Some(value), } } } impl StaticType for PixbufError { #[inline] #[doc(alias = "gdk_pixbuf_error_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::gdk_pixbuf_error_get_type()) } } } impl glib::HasParamSpec for PixbufError { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for PixbufError { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for PixbufError { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for PixbufError { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: PixbufError) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GdkPixbufRotation")] pub enum PixbufRotation { #[doc(alias = "GDK_PIXBUF_ROTATE_NONE")] None, #[doc(alias = "GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE")] Counterclockwise, #[doc(alias = "GDK_PIXBUF_ROTATE_UPSIDEDOWN")] Upsidedown, #[doc(alias = "GDK_PIXBUF_ROTATE_CLOCKWISE")] Clockwise, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for PixbufRotation { type GlibType = ffi::GdkPixbufRotation; #[inline] fn into_glib(self) -> ffi::GdkPixbufRotation { match self { Self::None => ffi::GDK_PIXBUF_ROTATE_NONE, Self::Counterclockwise => ffi::GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE, Self::Upsidedown => ffi::GDK_PIXBUF_ROTATE_UPSIDEDOWN, Self::Clockwise => ffi::GDK_PIXBUF_ROTATE_CLOCKWISE, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for PixbufRotation { #[inline] unsafe fn from_glib(value: ffi::GdkPixbufRotation) -> Self { match value { ffi::GDK_PIXBUF_ROTATE_NONE => Self::None, ffi::GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE => Self::Counterclockwise, ffi::GDK_PIXBUF_ROTATE_UPSIDEDOWN => Self::Upsidedown, ffi::GDK_PIXBUF_ROTATE_CLOCKWISE => Self::Clockwise, value => Self::__Unknown(value), } } } impl StaticType for PixbufRotation { #[inline] #[doc(alias = "gdk_pixbuf_rotation_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::gdk_pixbuf_rotation_get_type()) } } } impl glib::HasParamSpec for PixbufRotation { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for PixbufRotation { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for PixbufRotation { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for PixbufRotation { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: PixbufRotation) -> Self { ToValue::to_value(&v) } } gdk-pixbuf-0.20.9/src/auto/flags.rs000064400000000000000000000021421046102023000151540ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::ffi; use glib::{bitflags::bitflags, translate::*}; bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GdkPixbufFormatFlags")] pub struct PixbufFormatFlags: u32 { #[doc(alias = "GDK_PIXBUF_FORMAT_WRITABLE")] const WRITABLE = ffi::GDK_PIXBUF_FORMAT_WRITABLE as _; #[doc(alias = "GDK_PIXBUF_FORMAT_SCALABLE")] const SCALABLE = ffi::GDK_PIXBUF_FORMAT_SCALABLE as _; #[doc(alias = "GDK_PIXBUF_FORMAT_THREADSAFE")] const THREADSAFE = ffi::GDK_PIXBUF_FORMAT_THREADSAFE as _; } } #[doc(hidden)] impl IntoGlib for PixbufFormatFlags { type GlibType = ffi::GdkPixbufFormatFlags; #[inline] fn into_glib(self) -> ffi::GdkPixbufFormatFlags { self.bits() } } #[doc(hidden)] impl FromGlib for PixbufFormatFlags { #[inline] unsafe fn from_glib(value: ffi::GdkPixbufFormatFlags) -> Self { Self::from_bits_truncate(value) } } gdk-pixbuf-0.20.9/src/auto/mod.rs000064400000000000000000000016261046102023000146450ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT mod pixbuf; pub use self::pixbuf::Pixbuf; mod pixbuf_animation; pub use self::pixbuf_animation::PixbufAnimation; mod pixbuf_loader; pub use self::pixbuf_loader::PixbufLoader; mod pixbuf_non_anim; pub use self::pixbuf_non_anim::PixbufNonAnim; mod pixbuf_simple_anim; pub use self::pixbuf_simple_anim::PixbufSimpleAnim; mod pixbuf_format; pub use self::pixbuf_format::PixbufFormat; mod enums; pub use self::enums::Colorspace; pub use self::enums::InterpType; #[allow(deprecated)] pub use self::enums::PixbufAlphaMode; pub use self::enums::PixbufError; pub use self::enums::PixbufRotation; mod flags; pub use self::flags::PixbufFormatFlags; pub(crate) mod traits { pub use super::pixbuf_animation::PixbufAnimationExt; pub use super::pixbuf_loader::PixbufLoaderExt; } gdk-pixbuf-0.20.9/src/auto/pixbuf.rs000064400000000000000000000521131046102023000153600ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{ffi, Colorspace, InterpType, PixbufFormat, PixbufRotation}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GdkPixbuf")] pub struct Pixbuf(Object) @implements gio::Icon, gio::LoadableIcon; match fn { type_ => || ffi::gdk_pixbuf_get_type(), } } impl Pixbuf { #[doc(alias = "gdk_pixbuf_new")] pub fn new( colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, ) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_new( colorspace.into_glib(), has_alpha.into_glib(), bits_per_sample, width, height, )) } } #[doc(alias = "gdk_pixbuf_new_from_bytes")] #[doc(alias = "new_from_bytes")] pub fn from_bytes( data: &glib::Bytes, colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, rowstride: i32, ) -> Pixbuf { unsafe { from_glib_full(ffi::gdk_pixbuf_new_from_bytes( data.to_glib_none().0, colorspace.into_glib(), has_alpha.into_glib(), bits_per_sample, width, height, rowstride, )) } } //#[doc(alias = "gdk_pixbuf_new_from_data")] //#[doc(alias = "new_from_data")] //pub fn from_data(data: &[u8], colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, rowstride: i32, destroy_fn: Option) + 'static>>) -> Pixbuf { // unsafe { TODO: call ffi:gdk_pixbuf_new_from_data() } //} #[doc(alias = "gdk_pixbuf_new_from_file")] #[doc(alias = "new_from_file")] pub fn from_file(filename: impl AsRef) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_new_from_file(filename.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_new_from_file_at_scale")] #[doc(alias = "new_from_file_at_scale")] pub fn from_file_at_scale( filename: impl AsRef, width: i32, height: i32, preserve_aspect_ratio: bool, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_new_from_file_at_scale( filename.as_ref().to_glib_none().0, width, height, preserve_aspect_ratio.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_new_from_file_at_size")] #[doc(alias = "new_from_file_at_size")] pub fn from_file_at_size( filename: impl AsRef, width: i32, height: i32, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_new_from_file_at_size( filename.as_ref().to_glib_none().0, width, height, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_new_from_resource")] #[doc(alias = "new_from_resource")] pub fn from_resource(resource_path: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_new_from_resource(resource_path.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_new_from_resource_at_scale")] #[doc(alias = "new_from_resource_at_scale")] pub fn from_resource_at_scale( resource_path: &str, width: i32, height: i32, preserve_aspect_ratio: bool, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_new_from_resource_at_scale( resource_path.to_glib_none().0, width, height, preserve_aspect_ratio.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_new_from_stream")] #[doc(alias = "new_from_stream")] pub fn from_stream( stream: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_new_from_stream( stream.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_new_from_stream_at_scale")] #[doc(alias = "new_from_stream_at_scale")] pub fn from_stream_at_scale( stream: &impl IsA, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_new_from_stream_at_scale( stream.as_ref().to_glib_none().0, width, height, preserve_aspect_ratio.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_new_from_xpm_data")] #[doc(alias = "new_from_xpm_data")] pub fn from_xpm_data(data: &[&str]) -> Result { unsafe { Option::<_>::from_glib_full(ffi::gdk_pixbuf_new_from_xpm_data(data.to_glib_none().0)) .ok_or_else(|| glib::bool_error!("Invalid XPM data")) } } #[doc(alias = "gdk_pixbuf_add_alpha")] pub fn add_alpha( &self, substitute_color: bool, r: u8, g: u8, b: u8, ) -> Result { unsafe { Option::<_>::from_glib_full(ffi::gdk_pixbuf_add_alpha( self.to_glib_none().0, substitute_color.into_glib(), r, g, b, )) .ok_or_else(|| glib::bool_error!("Failed to add alpha channel")) } } #[doc(alias = "gdk_pixbuf_apply_embedded_orientation")] #[must_use] pub fn apply_embedded_orientation(&self) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_apply_embedded_orientation( self.to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_composite")] pub fn 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, ) { unsafe { ffi::gdk_pixbuf_composite( self.to_glib_none().0, dest.to_glib_none().0, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type.into_glib(), overall_alpha, ); } } #[doc(alias = "gdk_pixbuf_composite_color")] pub fn 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, ) { unsafe { ffi::gdk_pixbuf_composite_color( self.to_glib_none().0, dest.to_glib_none().0, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type.into_glib(), overall_alpha, check_x, check_y, check_size, color1, color2, ); } } #[doc(alias = "gdk_pixbuf_composite_color_simple")] #[must_use] pub fn composite_color_simple( &self, dest_width: i32, dest_height: i32, interp_type: InterpType, overall_alpha: i32, check_size: i32, color1: u32, color2: u32, ) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_composite_color_simple( self.to_glib_none().0, dest_width, dest_height, interp_type.into_glib(), overall_alpha, check_size, color1, color2, )) } } #[doc(alias = "gdk_pixbuf_copy")] #[must_use] pub fn copy(&self) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_copy(self.to_glib_none().0)) } } #[doc(alias = "gdk_pixbuf_copy_area")] pub fn copy_area( &self, src_x: i32, src_y: i32, width: i32, height: i32, dest_pixbuf: &Pixbuf, dest_x: i32, dest_y: i32, ) { unsafe { ffi::gdk_pixbuf_copy_area( self.to_glib_none().0, src_x, src_y, width, height, dest_pixbuf.to_glib_none().0, dest_x, dest_y, ); } } #[doc(alias = "gdk_pixbuf_copy_options")] pub fn copy_options(&self, dest_pixbuf: &Pixbuf) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_copy_options( self.to_glib_none().0, dest_pixbuf.to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_fill")] pub fn fill(&self, pixel: u32) { unsafe { ffi::gdk_pixbuf_fill(self.to_glib_none().0, pixel); } } #[doc(alias = "gdk_pixbuf_flip")] #[must_use] pub fn flip(&self, horizontal: bool) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_flip( self.to_glib_none().0, horizontal.into_glib(), )) } } #[doc(alias = "gdk_pixbuf_get_bits_per_sample")] #[doc(alias = "get_bits_per_sample")] #[doc(alias = "bits-per-sample")] pub fn bits_per_sample(&self) -> i32 { unsafe { ffi::gdk_pixbuf_get_bits_per_sample(self.to_glib_none().0) } } #[doc(alias = "gdk_pixbuf_get_byte_length")] #[doc(alias = "get_byte_length")] pub fn byte_length(&self) -> usize { unsafe { ffi::gdk_pixbuf_get_byte_length(self.to_glib_none().0) } } #[doc(alias = "gdk_pixbuf_get_colorspace")] #[doc(alias = "get_colorspace")] pub fn colorspace(&self) -> Colorspace { unsafe { from_glib(ffi::gdk_pixbuf_get_colorspace(self.to_glib_none().0)) } } #[doc(alias = "gdk_pixbuf_get_has_alpha")] #[doc(alias = "get_has_alpha")] #[doc(alias = "has-alpha")] pub fn has_alpha(&self) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_get_has_alpha(self.to_glib_none().0)) } } #[doc(alias = "gdk_pixbuf_get_height")] #[doc(alias = "get_height")] pub fn height(&self) -> i32 { unsafe { ffi::gdk_pixbuf_get_height(self.to_glib_none().0) } } #[doc(alias = "gdk_pixbuf_get_n_channels")] #[doc(alias = "get_n_channels")] #[doc(alias = "n-channels")] pub fn n_channels(&self) -> i32 { unsafe { ffi::gdk_pixbuf_get_n_channels(self.to_glib_none().0) } } #[doc(alias = "gdk_pixbuf_get_option")] #[doc(alias = "get_option")] pub fn option(&self, key: &str) -> Option { unsafe { from_glib_none(ffi::gdk_pixbuf_get_option( self.to_glib_none().0, key.to_glib_none().0, )) } } //#[doc(alias = "gdk_pixbuf_get_options")] //#[doc(alias = "get_options")] //pub fn options(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 } { // unsafe { TODO: call ffi:gdk_pixbuf_get_options() } //} #[doc(alias = "gdk_pixbuf_get_rowstride")] #[doc(alias = "get_rowstride")] pub fn rowstride(&self) -> i32 { unsafe { ffi::gdk_pixbuf_get_rowstride(self.to_glib_none().0) } } #[doc(alias = "gdk_pixbuf_get_width")] #[doc(alias = "get_width")] pub fn width(&self) -> i32 { unsafe { ffi::gdk_pixbuf_get_width(self.to_glib_none().0) } } #[doc(alias = "gdk_pixbuf_new_subpixbuf")] #[must_use] pub fn new_subpixbuf(&self, src_x: i32, src_y: i32, width: i32, height: i32) -> Pixbuf { unsafe { from_glib_full(ffi::gdk_pixbuf_new_subpixbuf( self.to_glib_none().0, src_x, src_y, width, height, )) } } #[doc(alias = "gdk_pixbuf_read_pixel_bytes")] pub fn read_pixel_bytes(&self) -> glib::Bytes { unsafe { from_glib_full(ffi::gdk_pixbuf_read_pixel_bytes(self.to_glib_none().0)) } } #[doc(alias = "gdk_pixbuf_remove_option")] pub fn remove_option(&self, key: &str) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_remove_option( self.to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_rotate_simple")] #[must_use] pub fn rotate_simple(&self, angle: PixbufRotation) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_rotate_simple( self.to_glib_none().0, angle.into_glib(), )) } } #[doc(alias = "gdk_pixbuf_saturate_and_pixelate")] pub fn saturate_and_pixelate(&self, dest: &Pixbuf, saturation: f32, pixelate: bool) { unsafe { ffi::gdk_pixbuf_saturate_and_pixelate( self.to_glib_none().0, dest.to_glib_none().0, saturation, pixelate.into_glib(), ); } } //#[doc(alias = "gdk_pixbuf_save")] //pub fn save(&self, filename: impl AsRef, type_: &str, error: Option<&mut glib::Error>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> bool { // unsafe { TODO: call ffi:gdk_pixbuf_save() } //} //#[doc(alias = "gdk_pixbuf_save_to_buffer")] //pub fn save_to_buffer(&self, type_: &str, error: Option<&mut glib::Error>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option> { // unsafe { TODO: call ffi:gdk_pixbuf_save_to_buffer() } //} //#[doc(alias = "gdk_pixbuf_save_to_callback")] //pub fn save_to_callback, usize, &glib::Error) -> bool>(&self, save_func: P, type_: &str, error: Option<&mut glib::Error>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> bool { // unsafe { TODO: call ffi:gdk_pixbuf_save_to_callback() } //} //#[doc(alias = "gdk_pixbuf_save_to_callbackv")] //pub fn save_to_callbackv, usize, &glib::Error) -> bool>(&self, save_func: P, type_: &str, option_keys: &[&str], option_values: &[&str]) -> Result<(), glib::Error> { // unsafe { TODO: call ffi:gdk_pixbuf_save_to_callbackv() } //} //#[doc(alias = "gdk_pixbuf_save_to_stream")] //pub fn save_to_stream(&self, stream: &impl IsA, type_: &str, cancellable: Option<&impl IsA>, error: Option<&mut glib::Error>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> bool { // unsafe { TODO: call ffi:gdk_pixbuf_save_to_stream() } //} //#[doc(alias = "gdk_pixbuf_save_to_stream_async")] //pub fn save_to_stream_async) + 'static>(&self, stream: &impl IsA, type_: &str, cancellable: Option<&impl IsA>, callback: P, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:gdk_pixbuf_save_to_stream_async() } //} // //pub fn save_to_stream_future(&self, stream: &(impl IsA + Clone + 'static), type_: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Pin> + 'static>> { //let stream = stream.clone(); //let type_ = String::from(type_); //Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { // obj.save_to_stream_async( // &stream, // &type_, // Some(cancellable), // , // move |res| { // send.resolve(res); // }, // ); //})) //} #[doc(alias = "gdk_pixbuf_scale")] pub fn 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, ) { unsafe { ffi::gdk_pixbuf_scale( self.to_glib_none().0, dest.to_glib_none().0, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type.into_glib(), ); } } #[doc(alias = "gdk_pixbuf_scale_simple")] #[must_use] pub fn scale_simple( &self, dest_width: i32, dest_height: i32, interp_type: InterpType, ) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_scale_simple( self.to_glib_none().0, dest_width, dest_height, interp_type.into_glib(), )) } } #[doc(alias = "gdk_pixbuf_set_option")] pub fn set_option(&self, key: &str, value: &str) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_set_option( self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0, )) } } #[doc(alias = "pixel-bytes")] pub fn pixel_bytes(&self) -> Option { ObjectExt::property(self, "pixel-bytes") } #[doc(alias = "gdk_pixbuf_calculate_rowstride")] pub fn calculate_rowstride( colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, ) -> i32 { unsafe { ffi::gdk_pixbuf_calculate_rowstride( colorspace.into_glib(), has_alpha.into_glib(), bits_per_sample, width, height, ) } } #[doc(alias = "gdk_pixbuf_get_formats")] #[doc(alias = "get_formats")] pub fn formats() -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(ffi::gdk_pixbuf_get_formats()) } } #[cfg(feature = "v2_40")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_40")))] #[doc(alias = "gdk_pixbuf_init_modules")] pub fn init_modules(path: &str) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::gdk_pixbuf_init_modules(path.to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } gdk-pixbuf-0.20.9/src/auto/pixbuf_animation.rs000064400000000000000000000142331046102023000174200ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{ffi, Pixbuf}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GdkPixbufAnimation")] pub struct PixbufAnimation(Object); match fn { type_ => || ffi::gdk_pixbuf_animation_get_type(), } } impl PixbufAnimation { pub const NONE: Option<&'static PixbufAnimation> = None; #[doc(alias = "gdk_pixbuf_animation_new_from_file")] #[doc(alias = "new_from_file")] pub fn from_file( filename: impl AsRef, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_animation_new_from_file( filename.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_animation_new_from_resource")] #[doc(alias = "new_from_resource")] pub fn from_resource(resource_path: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_animation_new_from_resource( resource_path.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_animation_new_from_stream")] #[doc(alias = "new_from_stream")] pub fn from_stream( stream: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_animation_new_from_stream( stream.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_animation_new_from_stream_async")] #[doc(alias = "new_from_stream_async")] pub fn from_stream_async) + 'static>( stream: &impl IsA, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn from_stream_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_animation_new_from_stream_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = from_stream_async_trampoline::

; unsafe { ffi::gdk_pixbuf_animation_new_from_stream_async( stream.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn from_stream_future( stream: &(impl IsA + Clone + 'static), ) -> Pin> + 'static>> { let stream = stream.clone(); Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { Self::from_stream_async(&stream, Some(cancellable), move |res| { send.resolve(res); }); })) } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PixbufAnimationExt: IsA + sealed::Sealed + 'static { #[doc(alias = "gdk_pixbuf_animation_get_height")] #[doc(alias = "get_height")] fn height(&self) -> i32 { unsafe { ffi::gdk_pixbuf_animation_get_height(self.as_ref().to_glib_none().0) } } #[doc(alias = "gdk_pixbuf_animation_get_static_image")] #[doc(alias = "get_static_image")] fn static_image(&self) -> Option { unsafe { from_glib_none(ffi::gdk_pixbuf_animation_get_static_image( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_animation_get_width")] #[doc(alias = "get_width")] fn width(&self) -> i32 { unsafe { ffi::gdk_pixbuf_animation_get_width(self.as_ref().to_glib_none().0) } } #[doc(alias = "gdk_pixbuf_animation_is_static_image")] fn is_static_image(&self) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_animation_is_static_image( self.as_ref().to_glib_none().0, )) } } } impl> PixbufAnimationExt for O {} gdk-pixbuf-0.20.9/src/auto/pixbuf_format.rs000064400000000000000000000067171046102023000167410ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::ffi; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct PixbufFormat(Boxed); match fn { copy => |ptr| ffi::gdk_pixbuf_format_copy(ptr), free => |ptr| ffi::gdk_pixbuf_format_free(ptr), type_ => || ffi::gdk_pixbuf_format_get_type(), } } impl PixbufFormat { #[doc(alias = "gdk_pixbuf_format_get_description")] #[doc(alias = "get_description")] pub fn description(&self) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_format_get_description(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "gdk_pixbuf_format_get_extensions")] #[doc(alias = "get_extensions")] pub fn extensions(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::gdk_pixbuf_format_get_extensions( mut_override(self.to_glib_none().0), )) } } #[doc(alias = "gdk_pixbuf_format_get_license")] #[doc(alias = "get_license")] pub fn license(&self) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_format_get_license(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "gdk_pixbuf_format_get_mime_types")] #[doc(alias = "get_mime_types")] pub fn mime_types(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::gdk_pixbuf_format_get_mime_types( mut_override(self.to_glib_none().0), )) } } #[doc(alias = "gdk_pixbuf_format_get_name")] #[doc(alias = "get_name")] pub fn name(&self) -> Option { unsafe { from_glib_full(ffi::gdk_pixbuf_format_get_name(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "gdk_pixbuf_format_is_disabled")] pub fn is_disabled(&self) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_format_is_disabled(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "gdk_pixbuf_format_is_save_option_supported")] pub fn is_save_option_supported(&self, option_key: &str) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_format_is_save_option_supported( mut_override(self.to_glib_none().0), option_key.to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_format_is_scalable")] pub fn is_scalable(&self) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_format_is_scalable(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "gdk_pixbuf_format_is_writable")] pub fn is_writable(&self) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_format_is_writable(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "gdk_pixbuf_format_set_disabled")] pub fn set_disabled(&mut self, disabled: bool) { unsafe { ffi::gdk_pixbuf_format_set_disabled(self.to_glib_none_mut().0, disabled.into_glib()); } } } unsafe impl Send for PixbufFormat {} unsafe impl Sync for PixbufFormat {} gdk-pixbuf-0.20.9/src/auto/pixbuf_loader.rs000064400000000000000000000213601046102023000167060ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{ffi, Pixbuf, PixbufAnimation, PixbufFormat}; use glib::{ object::ObjectType as _, prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GdkPixbufLoader")] pub struct PixbufLoader(Object); match fn { type_ => || ffi::gdk_pixbuf_loader_get_type(), } } impl PixbufLoader { pub const NONE: Option<&'static PixbufLoader> = None; #[doc(alias = "gdk_pixbuf_loader_new")] pub fn new() -> PixbufLoader { unsafe { from_glib_full(ffi::gdk_pixbuf_loader_new()) } } #[doc(alias = "gdk_pixbuf_loader_new_with_mime_type")] #[doc(alias = "new_with_mime_type")] pub fn with_mime_type(mime_type: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_loader_new_with_mime_type(mime_type.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_loader_new_with_type")] #[doc(alias = "new_with_type")] pub fn with_type(image_type: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::gdk_pixbuf_loader_new_with_type(image_type.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } impl Default for PixbufLoader { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PixbufLoaderExt: IsA + sealed::Sealed + 'static { #[doc(alias = "gdk_pixbuf_loader_close")] fn close(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::gdk_pixbuf_loader_close(self.as_ref().to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_loader_get_animation")] #[doc(alias = "get_animation")] fn animation(&self) -> Option { unsafe { from_glib_none(ffi::gdk_pixbuf_loader_get_animation( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_loader_get_format")] #[doc(alias = "get_format")] fn format(&self) -> Option { unsafe { from_glib_none(ffi::gdk_pixbuf_loader_get_format( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_loader_get_pixbuf")] #[doc(alias = "get_pixbuf")] fn pixbuf(&self) -> Option { unsafe { from_glib_none(ffi::gdk_pixbuf_loader_get_pixbuf( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_loader_set_size")] fn set_size(&self, width: i32, height: i32) { unsafe { ffi::gdk_pixbuf_loader_set_size(self.as_ref().to_glib_none().0, width, height); } } #[doc(alias = "gdk_pixbuf_loader_write")] fn write(&self, buf: &[u8]) -> Result<(), glib::Error> { let count = buf.len() as _; unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::gdk_pixbuf_loader_write( self.as_ref().to_glib_none().0, buf.to_glib_none().0, count, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_loader_write_bytes")] fn write_bytes(&self, buffer: &glib::Bytes) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::gdk_pixbuf_loader_write_bytes( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "area-prepared")] fn connect_area_prepared(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn area_prepared_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GdkPixbufLoader, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(PixbufLoader::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"area-prepared\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( area_prepared_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "area-updated")] fn connect_area_updated( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn area_updated_trampoline< P: IsA, F: Fn(&P, i32, i32, i32, i32) + 'static, >( this: *mut ffi::GdkPixbufLoader, x: std::ffi::c_int, y: std::ffi::c_int, width: std::ffi::c_int, height: std::ffi::c_int, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( PixbufLoader::from_glib_borrow(this).unsafe_cast_ref(), x, y, width, height, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"area-updated\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( area_updated_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "closed")] fn connect_closed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn closed_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GdkPixbufLoader, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(PixbufLoader::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"closed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( closed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "size-prepared")] fn connect_size_prepared(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn size_prepared_trampoline< P: IsA, F: Fn(&P, i32, i32) + 'static, >( this: *mut ffi::GdkPixbufLoader, width: std::ffi::c_int, height: std::ffi::c_int, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( PixbufLoader::from_glib_borrow(this).unsafe_cast_ref(), width, height, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"size-prepared\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( size_prepared_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> PixbufLoaderExt for O {} gdk-pixbuf-0.20.9/src/auto/pixbuf_non_anim.rs000064400000000000000000000013271046102023000172370ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{ffi, Pixbuf, PixbufAnimation}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GdkPixbufNonAnim")] pub struct PixbufNonAnim(Object) @extends PixbufAnimation; match fn { type_ => || ffi::gdk_pixbuf_non_anim_get_type(), } } impl PixbufNonAnim { #[doc(alias = "gdk_pixbuf_non_anim_new")] pub fn new(pixbuf: &Pixbuf) -> PixbufNonAnim { unsafe { PixbufAnimation::from_glib_full(ffi::gdk_pixbuf_non_anim_new(pixbuf.to_glib_none().0)) .unsafe_cast() } } } gdk-pixbuf-0.20.9/src/auto/pixbuf_simple_anim.rs000064400000000000000000000045271046102023000177430ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use crate::{ffi, Pixbuf, PixbufAnimation}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GdkPixbufSimpleAnim")] pub struct PixbufSimpleAnim(Object) @extends PixbufAnimation; match fn { type_ => || ffi::gdk_pixbuf_simple_anim_get_type(), } } impl PixbufSimpleAnim { #[doc(alias = "gdk_pixbuf_simple_anim_new")] pub fn new(width: i32, height: i32, rate: f32) -> PixbufSimpleAnim { unsafe { from_glib_full(ffi::gdk_pixbuf_simple_anim_new(width, height, rate)) } } #[doc(alias = "gdk_pixbuf_simple_anim_add_frame")] pub fn add_frame(&self, pixbuf: &Pixbuf) { unsafe { ffi::gdk_pixbuf_simple_anim_add_frame(self.to_glib_none().0, pixbuf.to_glib_none().0); } } #[doc(alias = "gdk_pixbuf_simple_anim_get_loop")] #[doc(alias = "get_loop")] #[doc(alias = "loop")] pub fn is_loop(&self) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_simple_anim_get_loop(self.to_glib_none().0)) } } #[doc(alias = "gdk_pixbuf_simple_anim_set_loop")] #[doc(alias = "loop")] pub fn set_loop(&self, loop_: bool) { unsafe { ffi::gdk_pixbuf_simple_anim_set_loop(self.to_glib_none().0, loop_.into_glib()); } } #[doc(alias = "loop")] pub fn connect_loop_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_loop_trampoline( this: *mut ffi::GdkPixbufSimpleAnim, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::loop\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_loop_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gdk-pixbuf-0.20.9/src/auto/versions.txt000064400000000000000000000002041046102023000161200ustar 00000000000000Generated by gir (https://github.com/gtk-rs/gir @ 2b05eaddce95) from gir-files (https://github.com/gtk-rs/gir-files @ 5089b7ff80cd) gdk-pixbuf-0.20.9/src/lib.rs000064400000000000000000000010511046102023000136540ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #![allow(clippy::manual_c_str_literals)] #![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] pub use gdk_pixbuf_sys as ffi; pub use gio; pub use glib; #[allow(clippy::too_many_arguments)] #[allow(clippy::manual_c_str_literals)] #[allow(unused_imports)] mod auto; pub mod subclass; mod pixbuf; mod pixbuf_animation; mod pixbuf_animation_iter; pub mod prelude; pub use self::pixbuf_animation_iter::PixbufAnimationIter; pub use crate::auto::*; gdk-pixbuf-0.20.9/src/pixbuf.rs000064400000000000000000000477611046102023000144250ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{future::Future, io::Read, mem, path::Path, pin::Pin, ptr, slice}; use glib::{prelude::*, translate::*, Error}; use libc::{c_uchar, c_void}; use crate::{ffi, Colorspace, Pixbuf, PixbufFormat}; impl Pixbuf { #[doc(alias = "gdk_pixbuf_new_from_data")] pub fn from_mut_slice>( data: T, colorspace: Colorspace, has_alpha: bool, bits_per_sample: i32, width: i32, height: i32, row_stride: i32, ) -> Pixbuf { unsafe extern "C" fn destroy>(_: *mut c_uchar, data: *mut c_void) { let _data: Box = Box::from_raw(data as *mut T); // the data will be destroyed now } assert!(width > 0, "width must be greater than 0"); assert!(height > 0, "height must be greater than 0"); assert!(row_stride > 0, "row_stride must be greater than 0"); assert_eq!( bits_per_sample, 8, "bits_per_sample == 8 is the only supported value" ); let width = width as usize; let height = height as usize; let row_stride = row_stride as usize; let bits_per_sample = bits_per_sample as usize; let n_channels = if has_alpha { 4 } else { 3 }; let last_row_len = width * ((n_channels * bits_per_sample + 7) / 8); let mut data: Box = Box::new(data); let ptr = { let data: &mut [u8] = (*data).as_mut(); assert!( data.len() >= ((height - 1) * row_stride + last_row_len), "data.len() must fit the width, height, and row_stride" ); data.as_mut_ptr() }; unsafe { from_glib_full(ffi::gdk_pixbuf_new_from_data( ptr, colorspace.into_glib(), has_alpha.into_glib(), bits_per_sample as i32, width as i32, height as i32, row_stride as i32, Some(destroy::), Box::into_raw(data) as *mut _, )) } } // rustdoc-stripper-ignore-next /// Creates a `Pixbuf` from a type implementing `Read` (like `File`). /// /// ```no_run /// use std::fs::File; /// use gdk_pixbuf::Pixbuf; /// /// let f = File::open("some_file.png").expect("failed to open image"); /// let pixbuf = Pixbuf::from_read(f).expect("failed to load image"); /// ``` pub fn from_read(r: R) -> Result { Pixbuf::from_stream(&gio::ReadInputStream::new(r), None::<&gio::Cancellable>) } #[doc(alias = "gdk_pixbuf_new_from_stream_async")] pub fn from_stream_async< P: IsA, Q: IsA, R: FnOnce(Result) + 'static, >( stream: &P, cancellable: Option<&Q>, callback: R, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|p| p.as_ref()); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn from_stream_async_trampoline< R: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let ptr = ffi::gdk_pixbuf_new_from_stream_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ptr)) } else { Err(from_glib_full(error)) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback = callback.into_inner(); callback(result); } let callback = from_stream_async_trampoline::; unsafe { ffi::gdk_pixbuf_new_from_stream_async( stream.as_ref().to_glib_none().0, cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } pub fn from_stream_future + Clone + 'static>( stream: &P, ) -> Pin> + 'static>> { let stream = stream.clone(); Box::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { Self::from_stream_async(&stream, Some(cancellable), move |res| { send.resolve(res); }); })) } #[doc(alias = "gdk_pixbuf_new_from_stream_at_scale_async")] pub fn from_stream_at_scale_async< P: IsA, Q: IsA, R: FnOnce(Result) + 'static, >( stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, cancellable: Option<&Q>, callback: R, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|p| p.as_ref()); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn from_stream_at_scale_async_trampoline< R: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let ptr = ffi::gdk_pixbuf_new_from_stream_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ptr)) } else { Err(from_glib_full(error)) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback = callback.into_inner(); callback(result); } let callback = from_stream_at_scale_async_trampoline::; unsafe { ffi::gdk_pixbuf_new_from_stream_at_scale_async( stream.as_ref().to_glib_none().0, width, height, preserve_aspect_ratio.into_glib(), cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } pub fn from_stream_at_scale_future + Clone + 'static>( stream: &P, width: i32, height: i32, preserve_aspect_ratio: bool, ) -> Pin> + 'static>> { let stream = stream.clone(); Box::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { Self::from_stream_at_scale_async( &stream, width, height, preserve_aspect_ratio, Some(cancellable), move |res| { send.resolve(res); }, ); })) } // rustdoc-stripper-ignore-next /// Returns a mutable slice to the pixbuf's pixel data. /// /// This function will cause an implicit copy if the pixbuf was created from read-only data. /// /// Please see the section on [image data](#image-data) for information about how the pixel /// data is stored in memory. /// /// # Safety /// No other reference to this pixbuf's data must exist when this method is called. /// /// Until you drop the returned reference, you must not call any methods on the pixbuf which may read /// or write to the data. #[allow(clippy::mut_from_ref)] #[allow(clippy::missing_safety_doc)] #[doc(alias = "gdk_pixbuf_get_pixels_with_length")] #[doc(alias = "get_pixels")] pub unsafe fn pixels(&self) -> &mut [u8] { let mut len = 0; let ptr = ffi::gdk_pixbuf_get_pixels_with_length(self.to_glib_none().0, &mut len); if len == 0 { return &mut []; } slice::from_raw_parts_mut(ptr, len as usize) } pub fn put_pixel(&self, x: u32, y: u32, red: u8, green: u8, blue: u8, alpha: u8) { assert!( x < self.width() as u32, "x must be less than the pixbuf's width" ); assert!( y < self.height() as u32, "y must be less than the pixbuf's height" ); unsafe { let x = x as usize; let y = y as usize; let n_channels = self.n_channels() as usize; assert!(n_channels == 3 || n_channels == 4); let rowstride = self.rowstride() as usize; let pixels = self.pixels(); let pos = y * rowstride + x * n_channels; pixels[pos] = red; pixels[pos + 1] = green; pixels[pos + 2] = blue; if n_channels == 4 { pixels[pos + 3] = alpha; } } } #[doc(alias = "gdk_pixbuf_get_file_info")] #[doc(alias = "get_file_info")] pub fn file_info>(filename: T) -> Option<(PixbufFormat, i32, i32)> { unsafe { let mut width = mem::MaybeUninit::uninit(); let mut height = mem::MaybeUninit::uninit(); let ret = ffi::gdk_pixbuf_get_file_info( filename.as_ref().to_glib_none().0, width.as_mut_ptr(), height.as_mut_ptr(), ); if !ret.is_null() { Some(( from_glib_none(ret), width.assume_init(), height.assume_init(), )) } else { None } } } #[doc(alias = "gdk_pixbuf_get_file_info_async")] #[doc(alias = "get_file_info_async")] pub fn file_info_async< P: IsA, Q: FnOnce(Result, Error>) + 'static, T: AsRef, >( filename: T, cancellable: Option<&P>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|p| p.as_ref()); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn get_file_info_async_trampoline< Q: FnOnce(Result, Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let mut width = mem::MaybeUninit::uninit(); let mut height = mem::MaybeUninit::uninit(); let ret = ffi::gdk_pixbuf_get_file_info_finish( res, width.as_mut_ptr(), height.as_mut_ptr(), &mut error, ); let result = if !error.is_null() { Err(from_glib_full(error)) } else if ret.is_null() { Ok(None) } else { Ok(Some(( from_glib_none(ret), width.assume_init(), height.assume_init(), ))) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback = callback.into_inner(); callback(result); } let callback = get_file_info_async_trampoline::; unsafe { ffi::gdk_pixbuf_get_file_info_async( filename.as_ref().to_glib_none().0, cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[allow(clippy::type_complexity)] #[doc(alias = "get_file_info_async")] pub fn file_info_future + Clone + 'static>( filename: T, ) -> Pin, Error>> + 'static>> { Box::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { Self::file_info_async(filename, Some(cancellable), move |res| { send.resolve(res); }); })) } #[doc(alias = "gdk_pixbuf_save_to_bufferv")] pub fn save_to_bufferv(&self, type_: &str, options: &[(&str, &str)]) -> Result, Error> { unsafe { let mut buffer = ptr::null_mut(); let mut buffer_size = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let option_keys: Vec<&str> = options.iter().map(|o| o.0).collect(); let option_values: Vec<&str> = options.iter().map(|o| o.1).collect(); let _ = ffi::gdk_pixbuf_save_to_bufferv( self.to_glib_none().0, &mut buffer, buffer_size.as_mut_ptr(), type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibContainer::from_glib_full_num( buffer, buffer_size.assume_init() as _, )) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_save_to_streamv")] pub fn save_to_streamv, Q: IsA>( &self, stream: &P, type_: &str, options: &[(&str, &str)], cancellable: Option<&Q>, ) -> Result<(), Error> { let cancellable = cancellable.map(|p| p.as_ref()); unsafe { let mut error = ptr::null_mut(); let option_keys: Vec<&str> = options.iter().map(|o| o.0).collect(); let option_values: Vec<&str> = options.iter().map(|o| o.1).collect(); let _ = ffi::gdk_pixbuf_save_to_streamv( self.to_glib_none().0, stream.as_ref().to_glib_none().0, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "gdk_pixbuf_save_to_streamv_async")] pub fn save_to_streamv_async< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + 'static, >( &self, stream: &P, type_: &str, options: &[(&str, &str)], cancellable: Option<&Q>, callback: R, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|p| p.as_ref()); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn save_to_streamv_async_trampoline< R: FnOnce(Result<(), Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let _ = ffi::gdk_pixbuf_save_to_stream_finish(res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback = callback.into_inner(); callback(result); } let callback = save_to_streamv_async_trampoline::; unsafe { let option_keys: Vec<&str> = options.iter().map(|o| o.0).collect(); let option_values: Vec<&str> = options.iter().map(|o| o.1).collect(); ffi::gdk_pixbuf_save_to_streamv_async( self.to_glib_none().0, stream.as_ref().to_glib_none().0, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } pub fn save_to_streamv_future + Clone + 'static>( &self, stream: &P, type_: &str, options: &[(&str, &str)], ) -> Pin> + 'static>> { let stream = stream.clone(); let type_ = String::from(type_); let options = options .iter() .map(|&(k, v)| (String::from(k), String::from(v))) .collect::>(); Box::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { let options = options .iter() .map(|(k, v)| (k.as_str(), v.as_str())) .collect::>(); obj.save_to_streamv_async( &stream, &type_, options.as_slice(), Some(cancellable), move |res| { send.resolve(res); }, ); })) } #[doc(alias = "gdk_pixbuf_savev")] pub fn savev>( &self, filename: T, type_: &str, options: &[(&str, &str)], ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let option_keys: Vec<&str> = options.iter().map(|o| o.0).collect(); let option_values: Vec<&str> = options.iter().map(|o| o.1).collect(); let _ = ffi::gdk_pixbuf_savev( self.to_glib_none().0, filename.as_ref().to_glib_none().0, type_.to_glib_none().0, option_keys.to_glib_none().0, option_values.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } gdk-pixbuf-0.20.9/src/pixbuf_animation.rs000064400000000000000000000024071046102023000164500ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{ptr, time::SystemTime}; use glib::{prelude::*, translate::*}; use crate::{ffi, PixbufAnimation, PixbufAnimationIter}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PixbufAnimationExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gdk_pixbuf_animation_get_iter")] #[doc(alias = "get_iter")] fn iter(&self, start_time: Option) -> PixbufAnimationIter { let start_time = start_time.map(|s| { let diff = s .duration_since(SystemTime::UNIX_EPOCH) .expect("failed to convert time"); glib::ffi::GTimeVal { tv_sec: diff.as_secs() as _, tv_usec: diff.subsec_micros() as _, } }); unsafe { from_glib_full(ffi::gdk_pixbuf_animation_get_iter( self.as_ref().to_glib_none().0, start_time .as_ref() .map(|t| t as *const glib::ffi::GTimeVal) .unwrap_or(ptr::null()), )) } } } impl> PixbufAnimationExtManual for O {} gdk-pixbuf-0.20.9/src/pixbuf_animation_iter.rs000064400000000000000000000037461046102023000175020ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::time::{Duration, SystemTime}; use glib::translate::*; use super::{ffi, Pixbuf}; glib::wrapper! { #[doc(alias = "GdkPixbufAnimationIter")] pub struct PixbufAnimationIter(Object); match fn { type_ => || ffi::gdk_pixbuf_animation_iter_get_type(), } } impl PixbufAnimationIter { #[doc(alias = "gdk_pixbuf_animation_iter_advance")] pub fn advance(&self, current_time: SystemTime) -> bool { let diff = current_time .duration_since(SystemTime::UNIX_EPOCH) .expect("failed to convert time"); unsafe { from_glib(ffi::gdk_pixbuf_animation_iter_advance( self.to_glib_none().0, &glib::ffi::GTimeVal { tv_sec: diff.as_secs() as _, tv_usec: diff.subsec_micros() as _, }, )) } } #[doc(alias = "gdk_pixbuf_animation_iter_get_pixbuf")] #[doc(alias = "get_pixbuf")] pub fn pixbuf(&self) -> Pixbuf { unsafe { from_glib_none(ffi::gdk_pixbuf_animation_iter_get_pixbuf( self.to_glib_none().0, )) } } #[doc(alias = "gdk_pixbuf_animation_iter_get_delay_time")] #[doc(alias = "get_delay_time")] pub fn delay_time(&self) -> Option { unsafe { let res = ffi::gdk_pixbuf_animation_iter_get_delay_time(self.to_glib_none().0); if res < 0 { None } else { Some(Duration::from_millis(res as u64)) } } } #[doc(alias = "gdk_pixbuf_animation_iter_on_currently_loading_frame")] pub fn on_currently_loading_frame(&self) -> bool { unsafe { from_glib(ffi::gdk_pixbuf_animation_iter_on_currently_loading_frame( self.to_glib_none().0, )) } } } gdk-pixbuf-0.20.9/src/prelude.rs000064400000000000000000000004741046102023000145560ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for blanket imports. #[doc(hidden)] pub use glib::prelude::*; #[doc(hidden)] pub use gio::prelude::*; pub use crate::{auto::traits::*, pixbuf_animation::PixbufAnimationExtManual}; gdk-pixbuf-0.20.9/src/subclass/mod.rs000064400000000000000000000011221046102023000155030ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for creating custom types. pub mod pixbuf_animation; pub mod pixbuf_animation_iter; pub mod pixbuf_loader; pub mod prelude { pub use glib::subclass::prelude::*; pub use gio::subclass::prelude::*; pub use super::{ pixbuf_animation::{PixbufAnimationImpl, PixbufAnimationImplExt}, pixbuf_animation_iter::{PixbufAnimationIterImpl, PixbufAnimationIterImplExt}, pixbuf_loader::{PixbufLoaderImpl, PixbufLoaderImplExt}, }; } gdk-pixbuf-0.20.9/src/subclass/pixbuf_animation.rs000064400000000000000000000147621046102023000202760ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`PixbufAnimation`]. use std::{ mem::MaybeUninit, sync::OnceLock, time::{Duration, SystemTime}, }; use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, Pixbuf, PixbufAnimation, PixbufAnimationIter}; pub trait PixbufAnimationImpl: ObjectImpl { fn is_static_image(&self) -> bool { self.parent_is_static_image() } fn static_image(&self) -> Option { self.parent_static_image() } fn size(&self) -> (i32, i32) { self.parent_size() } fn iter(&self, start_time: SystemTime) -> PixbufAnimationIter { self.parent_iter(start_time) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait PixbufAnimationImplExt: sealed::Sealed + ObjectSubclass { fn parent_is_static_image(&self) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufAnimationClass; let f = (*parent_class) .is_static_image .expect("No parent class implementation for \"is_static_image\""); from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) } } fn parent_static_image(&self) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufAnimationClass; let f = (*parent_class) .get_static_image .expect("No parent class implementation for \"get_static_image\""); from_glib_none(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) } } fn parent_size(&self) -> (i32, i32) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufAnimationClass; let f = (*parent_class) .get_size .expect("No parent class implementation for \"get_size\""); let mut width = MaybeUninit::uninit(); let mut height = MaybeUninit::uninit(); f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, width.as_mut_ptr(), height.as_mut_ptr(), ); (width.assume_init(), height.assume_init()) } } fn parent_iter(&self, start_time: SystemTime) -> PixbufAnimationIter { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufAnimationClass; let f = (*parent_class) .get_iter .expect("No parent class implementation for \"get_iter\""); let diff = start_time .duration_since(SystemTime::UNIX_EPOCH) .expect("failed to convert time"); let time = glib::ffi::GTimeVal { tv_sec: diff.as_secs() as _, tv_usec: diff.subsec_micros() as _, }; from_glib_full(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, &time, )) } } } impl PixbufAnimationImplExt for T {} unsafe impl IsSubclassable for PixbufAnimation { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.get_static_image = Some(animation_get_static_image::); klass.get_size = Some(animation_get_size::); klass.get_iter = Some(animation_get_iter::); klass.is_static_image = Some(animation_is_static_image::); } } unsafe extern "C" fn animation_is_static_image( ptr: *mut ffi::GdkPixbufAnimation, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.is_static_image().into_glib() } unsafe extern "C" fn animation_get_size( ptr: *mut ffi::GdkPixbufAnimation, width_ptr: *mut libc::c_int, height_ptr: *mut libc::c_int, ) { if width_ptr.is_null() && height_ptr.is_null() { return; } let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let (width, height) = imp.size(); if !width_ptr.is_null() { *width_ptr = width; } if !height_ptr.is_null() { *height_ptr = height; } } unsafe extern "C" fn animation_get_static_image( ptr: *mut ffi::GdkPixbufAnimation, ) -> *mut ffi::GdkPixbuf { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let instance = imp.obj(); let static_image = imp.static_image(); // Ensure that a) the static image stays alive as long as the animation instance and b) that // the same static image is returned every time. This is a requirement by the gdk-pixbuf API. let static_image_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| glib::Quark::from_str("gtk-rs-subclass-static-image")) }; if let Some(old_image) = instance.qdata::>(static_image_quark) { let old_image = old_image.as_ref(); if let Some(old_image) = old_image { assert_eq!( Some(old_image), static_image.as_ref(), "Did not return same static image again" ); } } instance.set_qdata(static_image_quark, static_image.clone()); static_image.to_glib_none().0 } unsafe extern "C" fn animation_get_iter( ptr: *mut ffi::GdkPixbufAnimation, start_time_ptr: *const glib::ffi::GTimeVal, ) -> *mut ffi::GdkPixbufAnimationIter { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let start_time = SystemTime::UNIX_EPOCH + Duration::from_secs((*start_time_ptr).tv_sec.try_into().unwrap()) + Duration::from_micros((*start_time_ptr).tv_usec.try_into().unwrap()); imp.iter(start_time).into_glib_ptr() } gdk-pixbuf-0.20.9/src/subclass/pixbuf_animation_iter.rs000064400000000000000000000137061046102023000213160ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`PixbufAnimationIter`]. use std::{ sync::OnceLock, time::{Duration, SystemTime}, }; use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, Pixbuf, PixbufAnimationIter}; pub trait PixbufAnimationIterImpl: ObjectImpl { // rustdoc-stripper-ignore-next /// Time in milliseconds, returning `None` implies showing the same pixbuf forever. fn delay_time(&self) -> Option { self.parent_delay_time() } fn pixbuf(&self) -> Pixbuf { self.parent_pixbuf() } fn on_currently_loading_frame(&self) -> bool { self.parent_on_currently_loading_frame() } fn advance(&self, current_time: SystemTime) -> bool { self.parent_advance(current_time) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait PixbufAnimationIterImplExt: sealed::Sealed + ObjectSubclass { fn parent_delay_time(&self) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufAnimationIterClass; let f = (*parent_class) .get_delay_time .expect("No parent class implementation for \"get_delay_time\""); let time = f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0); if time < 0 { None } else { Some(Duration::from_millis(time as u64)) } } } fn parent_pixbuf(&self) -> Pixbuf { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufAnimationIterClass; let f = (*parent_class) .get_pixbuf .expect("No parent class implementation for \"get_pixbuf\""); from_glib_none(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) } } fn parent_on_currently_loading_frame(&self) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufAnimationIterClass; let f = (*parent_class) .on_currently_loading_frame .expect("No parent class implementation for \"on_currently_loading_frame\""); from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) } } fn parent_advance(&self, current_time: SystemTime) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufAnimationIterClass; let f = (*parent_class) .advance .expect("No parent class implementation for \"advance\""); let diff = current_time .duration_since(SystemTime::UNIX_EPOCH) .expect("failed to convert time"); let time = glib::ffi::GTimeVal { tv_sec: diff.as_secs() as _, tv_usec: diff.subsec_micros() as _, }; from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, &time, )) } } } impl PixbufAnimationIterImplExt for T {} unsafe impl IsSubclassable for PixbufAnimationIter { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.get_delay_time = Some(animation_iter_get_delay_time::); klass.get_pixbuf = Some(animation_iter_get_pixbuf::); klass.on_currently_loading_frame = Some(animation_iter_on_currently_loading_frame::); klass.advance = Some(animation_iter_advance::); } } unsafe extern "C" fn animation_iter_get_delay_time( ptr: *mut ffi::GdkPixbufAnimationIter, ) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.delay_time().map(|t| t.as_millis() as i32).unwrap_or(-1) } unsafe extern "C" fn animation_iter_get_pixbuf( ptr: *mut ffi::GdkPixbufAnimationIter, ) -> *mut ffi::GdkPixbuf { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let pixbuf = imp.pixbuf(); // Ensure that the pixbuf stays alive until the next call let pixbuf_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| glib::Quark::from_str("gtk-rs-subclass-pixbuf")) }; imp.obj().set_qdata(pixbuf_quark, pixbuf.clone()); pixbuf.to_glib_none().0 } unsafe extern "C" fn animation_iter_on_currently_loading_frame( ptr: *mut ffi::GdkPixbufAnimationIter, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.on_currently_loading_frame().into_glib() } unsafe extern "C" fn animation_iter_advance( ptr: *mut ffi::GdkPixbufAnimationIter, current_time_ptr: *const glib::ffi::GTimeVal, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let current_time = SystemTime::UNIX_EPOCH + Duration::from_secs((*current_time_ptr).tv_sec.try_into().unwrap()) + Duration::from_micros((*current_time_ptr).tv_usec.try_into().unwrap()); imp.advance(current_time).into_glib() } gdk-pixbuf-0.20.9/src/subclass/pixbuf_loader.rs000064400000000000000000000103621046102023000175550ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`PixbufLoader`]. use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, PixbufLoader}; pub trait PixbufLoaderImpl: ObjectImpl { fn size_prepared(&self, width: i32, height: i32) { self.parent_size_prepared(width, height) } fn area_prepared(&self) { self.parent_area_prepared() } fn area_updated(&self, x: i32, y: i32, width: i32, height: i32) { self.parent_area_updated(x, y, width, height) } fn closed(&self) { self.parent_closed() } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait PixbufLoaderImplExt: sealed::Sealed + ObjectSubclass { fn parent_size_prepared(&self, width: i32, height: i32) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufLoaderClass; if let Some(f) = (*parent_class).size_prepared { f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, width, height, ) } } } fn parent_area_prepared(&self) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufLoaderClass; if let Some(f) = (*parent_class).area_prepared { f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0) } } } fn parent_area_updated(&self, x: i32, y: i32, width: i32, height: i32) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufLoaderClass; if let Some(f) = (*parent_class).area_updated { f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, x, y, width, height, ) } } } fn parent_closed(&self) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GdkPixbufLoaderClass; if let Some(f) = (*parent_class).closed { f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0) } } } } impl PixbufLoaderImplExt for T {} unsafe impl IsSubclassable for PixbufLoader { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.size_prepared = Some(loader_size_prepared::); klass.area_prepared = Some(loader_area_prepared::); klass.area_updated = Some(loader_area_updated::); klass.closed = Some(loader_closed::); } } unsafe extern "C" fn loader_size_prepared( ptr: *mut ffi::GdkPixbufLoader, width: i32, height: i32, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.size_prepared(width, height) } unsafe extern "C" fn loader_area_prepared(ptr: *mut ffi::GdkPixbufLoader) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.area_prepared(); } unsafe extern "C" fn loader_area_updated( ptr: *mut ffi::GdkPixbufLoader, x: i32, y: i32, width: i32, height: i32, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.area_updated(x, y, width, height) } unsafe extern "C" fn loader_closed(ptr: *mut ffi::GdkPixbufLoader) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.closed() } gdk-pixbuf-0.20.9/tests/check_gir.rs000064400000000000000000000003461046102023000154050ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[test] fn check_gir_file() { let res = gir_format_check::check_gir_file("Gir.toml"); println!("{res}"); assert_eq!(res.nb_errors, 0); } gdk-pixbuf-0.20.9/tests/overflow.rs000064400000000000000000000052331046102023000153320ustar 00000000000000use gdk_pixbuf::*; #[test] #[cfg(target_pointer_width = "64")] fn put_pixel_doesnt_overflow() { // Only test this on 64-bit boxes; otherwise we can't even // allocate a pixbuf this big. let pixbuf = Pixbuf::new(Colorspace::Rgb, true, 8, 21000, 29700).unwrap(); // debug build: thread 'put_pixel_doesnt_overflow' panicked at // 'attempt to multiply with overflow', src/pixbuf.rs:274:24 // // release build: thread 'put_pixel_doesnt_overflow' panicked at // 'index out of bounds: the len is 2494800000, but the index is // 18446744071598664320', src/pixbuf.rs:276:13 pixbuf.put_pixel(20000, 26000, 255, 255, 255, 255); } #[test] #[cfg(target_pointer_width = "64")] fn new_from_mut_slice_doesnt_overflow() { // Only test this on 64-bit boxes; otherwise we can't even // allocate a pixbuf this big. // Plus 5 to test that new_from_mut_slice() can ignore trailing data past the last row let data = vec![0u8; 21000 * 4 * 29700 + 5]; // debug build: thread 'new_from_mut_slice_doesnt_overflow' // panicked at 'attempt to multiply with overflow', // /home/federico/src/gtk-rs/gdk-pixbuf/src/pixbuf.rs:50:36 // // release build: thread 'new_from_mut_slice_doesnt_overflow' // panicked at 'assertion failed: data.len() == ((height - 1) * // row_stride + last_row_len) as usize', src/pixbuf.rs:50:13 let _pixbuf = Pixbuf::from_mut_slice(data, Colorspace::Rgb, true, 8, 21000, 29700, 21000 * 4); } #[test] #[should_panic] fn put_pixel_out_of_bounds_x_should_panic() { let pixbuf = Pixbuf::new(Colorspace::Rgb, true, 8, 100, 200).unwrap(); pixbuf.put_pixel(100, 0, 0, 0, 0, 0); } #[test] #[should_panic] fn put_pixel_out_of_bounds_y_should_panic() { let pixbuf = Pixbuf::new(Colorspace::Rgb, true, 8, 100, 200).unwrap(); pixbuf.put_pixel(0, 200, 0, 0, 0, 0); } #[test] #[should_panic] fn too_small_slice_should_panic() { let data = vec![0u8; 100 * 99 * 4]; Pixbuf::from_mut_slice(data, Colorspace::Rgb, true, 8, 100, 100, 100 * 4); } #[test] fn last_row_with_incomplete_rowstride_works() { // 1-pixel wide, RGB, 3 32-bit rows, no extra padding byte on the fourth row let data = vec![0u8; 4 * 3 + 3]; Pixbuf::from_mut_slice(data, Colorspace::Rgb, false, 8, 1, 4, 4); } #[test] fn last_row_with_full_rowstride_works() { // 1-pixel wide, RGB, 4 32-bit rows let data = vec![0u8; 4 * 4]; Pixbuf::from_mut_slice(data, Colorspace::Rgb, false, 8, 1, 4, 4); } #[test] fn extra_data_after_last_row_works() { // 1-pixel wide, RGB, 4 32-bit rows, plus some extra space let data = vec![0u8; 4 * 4 + 42]; Pixbuf::from_mut_slice(data, Colorspace::Rgb, false, 8, 1, 4, 4); }