skia_safe/codec/
pixmap_utils.rs

1use crate::{prelude::*, EncodedOrigin, ImageInfo, Pixmap};
2use skia_bindings as sb;
3
4/// Copy the pixels in src into dst, applying the orientation transformations specified
5/// by origin. If the inputs are invalid, this returns `false` and no copy is made.
6/// # Safety
7/// Unsafe in that it modifies the underlying pixels of `dst`.
8pub unsafe fn orient(dst: &mut Pixmap, src: &Pixmap, origin: EncodedOrigin) -> bool {
9    sb::C_SkPixmapUtils_Orient(dst.native_mut(), src.native(), origin.into_native())
10}
11
12/// Return a copy of the provided ImageInfo with the width and height swapped.
13pub fn swap_width_height(info: &ImageInfo) -> ImageInfo {
14    ImageInfo::construct(|ii| unsafe { sb::C_SkPixmapUtils_SwapWidthHeight(ii, info.native()) })
15}