Skip to content

Commit

Permalink
imagekit: Add api-13 bindings
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Jan 9, 2025
1 parent 27dfbd8 commit e4f42e8
Show file tree
Hide file tree
Showing 13 changed files with 1,199 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions components/multimedia/image_framework/src/native_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ pub mod image;
pub mod image_packer;
pub mod image_receiver;
pub mod image_source;
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub mod picture;
pub mod pixelmap;
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ pub struct Image_String {
/// data lenth for string type
pub size: usize,
}
/// Define a PictureMetadata struct type, used for picture metadata.
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
#[repr(C)]
pub struct OH_PictureMetadata {
_unused: [u8; 0],
}
/// Defines the image encode format.
///
///
Expand Down Expand Up @@ -122,6 +132,16 @@ impl Image_ErrorCode {
}
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
impl Image_ErrorCode {
/// unsupported memory format
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub const IMAGE_UNSUPPORTED_MEMORY_FORMAT: Image_ErrorCode = Image_ErrorCode(7600205);
}
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
impl Image_ErrorCode {
/// failed to allocate memory
pub const IMAGE_ALLOC_FAILED: Image_ErrorCode = Image_ErrorCode(7600301);
Expand Down Expand Up @@ -165,6 +185,25 @@ impl Image_ErrorCode {
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[derive(Clone, Hash, PartialEq, Eq)]
pub struct Image_ErrorCode(pub ::core::ffi::c_uint);
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
impl Image_MetadataType {
pub const EXIF_METADATA: Image_MetadataType = Image_MetadataType(1);
}
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
impl Image_MetadataType {
pub const FRAGMENT_METADATA: Image_MetadataType = Image_MetadataType(2);
}
#[repr(transparent)]
/// Define the metadata type.
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
#[derive(Clone, Hash, PartialEq, Eq)]
pub struct Image_MetadataType(pub ::core::ffi::c_uint);
/// Defines the bmp mime type.
///
///
Expand Down Expand Up @@ -1365,3 +1404,153 @@ pub const OHOS_IMAGE_PROPERTY_WIND_SNAPSHOT_MODE: &::core::ffi::CStr = c"HwMnote
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub const OHOS_IMAGE_PROPERTY_GIF_LOOP_COUNT: &::core::ffi::CStr = c"GIFLoopCount";
/// X in original
/// It is used in [`OH_ImageSource_GetImageProperty`].
/// The top left corner of the fragment image is at the X-coordinate of the original image
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub const OHOS_IMAGE_PROPERTY_X_IN_ORIGINAL: &::core::ffi::CStr = c"XInOriginal";
/// Y in original
/// It is used in [`OH_ImageSource_GetImageProperty`].
/// The top left corner of the fragment image is at the Y-coordinate of the original image
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub const OHOS_IMAGE_PROPERTY_Y_IN_ORIGINAL: &::core::ffi::CStr = c"YInOriginal";
/// Fragment map width
/// It is used in [`OH_ImageSource_GetImageProperty`].
/// The width of the fragment image
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub const OHOS_IMAGE_PROPERTY_FRAGMENT_WIDTH: &::core::ffi::CStr = c"FragmentImageWidth";
/// Fragment map height
/// It is used in [`OH_ImageSource_GetImageProperty`].
/// The height of the fragment image
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub const OHOS_IMAGE_PROPERTY_FRAGMENT_HEIGHT: &::core::ffi::CStr = c"FragmentImageHeight";
extern "C" {
/// Creates a <b>PictureMetadata</b> object.
///
/// # Arguments
///
/// `metadataType` - The type of metadata.
///
/// `metadata` - The PictureMetadata pointer will be operated.
///
/// # Returns
///
/// Image functions result code.
/// [`IMAGE_SUCCESS`] if the execution is successful.
/// [`IMAGE_BAD_PARAMETER`] metadata is nullptr.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_PictureMetadata_Create(
metadataType: Image_MetadataType,
metadata: *mut *mut OH_PictureMetadata,
) -> Image_ErrorCode;
/// Obtains the property of picture metadata.
///
/// # Arguments
///
/// `metadata` - The PictureMetadata pointer will be operated.
///
/// `key` - The property's key.
///
/// `value` - The property's value.
///
/// # Returns
///
/// Image functions result code.
/// [`IMAGE_SUCCESS`] if the execution is successful.
/// [`IMAGE_BAD_PARAMETER`] metadata is nullptr, or key is nullptr, or value is nullptr.
/// [`IMAGE_UNSUPPORTED_METADATA`] unsupported metadata type, or the metadata type does not match the
/// auxiliary picture type.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_PictureMetadata_GetProperty(
metadata: *mut OH_PictureMetadata,
key: *mut Image_String,
value: *mut Image_String,
) -> Image_ErrorCode;
/// Set picture metadata property.
///
/// # Arguments
///
/// `metadata` - The PictureMetadata pointer will be operated.
///
/// `key` - The property's key.
///
/// `value` - The property's value.
///
/// # Returns
///
/// Image functions result code.
/// [`IMAGE_SUCCESS`] if the execution is successful.
/// [`IMAGE_BAD_PARAMETER`] metadata is nullptr, or key is nullptr, or value is nullptr.
/// [`IMAGE_UNSUPPORTED_METADATA`] unsupported metadata type, or the metadata type does not match the
/// auxiliary picture type.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_PictureMetadata_SetProperty(
metadata: *mut OH_PictureMetadata,
key: *mut Image_String,
value: *mut Image_String,
) -> Image_ErrorCode;
/// Releases this PictureMetadata object.
///
/// # Arguments
///
/// `metadata` - The PictureMetadata pointer will be operated.
///
/// # Returns
///
/// Image functions result code.
/// [`IMAGE_SUCCESS`] if the execution is successful.
/// [`IMAGE_BAD_PARAMETER`] metadata is nullptr.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_PictureMetadata_Release(metadata: *mut OH_PictureMetadata) -> Image_ErrorCode;
/// Obtains a clone of metadata.
///
/// # Arguments
///
/// `oldMetadata` - The PictureMetadata pointer will be operated.
///
/// `newMetadata` - The PictureMetadata pointer will be cloned.
///
/// # Returns
///
/// Image functions result code.
/// [`IMAGE_SUCCESS`] if the execution is successful.
/// [`IMAGE_BAD_PARAMETER`] metadata is nullptr.
/// [`IMAGE_ALLOC_FAILED`] memory alloc failed.
/// [`IMAGE_COPY_FAILED`] memory copy failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_PictureMetadata_Clone(
oldMetadata: *mut OH_PictureMetadata,
newMetadata: *mut *mut OH_PictureMetadata,
) -> Image_ErrorCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::native_image::common::*;
#[cfg(feature = "api-13")]
use crate::native_image::picture::OH_PictureNative;
use ohos_sys_opaque_types::OH_PixelmapNative;

/// Define a ImagePacker struct type, used for ImagePacker pointer controls.
Expand Down Expand Up @@ -275,6 +277,38 @@ extern "C" {
outData: *mut u8,
size: *mut usize,
) -> Image_ErrorCode;
/// Encoding a <b>Picture</b> into the data with required format.
///
/// # Arguments
///
/// `imagePacker` - The imagePacker to use for packing.
///
/// `options` - Indicates the encoding [`OH_PackingOptions`].
///
/// `picture` - The picture to be packed.
///
/// `outData` - The output data buffer to store the packed image.
///
/// `size` - A pointer to the size of the output data buffer.
///
/// # Returns
///
/// Image functions result code.
/// [`IMAGE_SUCCESS`] if the execution is successful.
/// [`IMAGE_BAD_PARAMETER`] imagePacker is nullptr, or picture is nullptr, or outData is nullptr,
/// or size is invalid.
/// [`IMAGE_ENCODE_FAILED`] encode failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImagePackerNative_PackToDataFromPicture(
imagePacker: *mut OH_ImagePackerNative,
options: *mut OH_PackingOptions,
picture: *mut OH_PictureNative,
outData: *mut u8,
size: *mut usize,
) -> Image_ErrorCode;
/// Encoding a <b>Pixelmap</b> into the a file with fd with required format
///
/// # Arguments
Expand All @@ -300,6 +334,34 @@ extern "C" {
pixelmap: *mut OH_PixelmapNative,
fd: i32,
) -> Image_ErrorCode;
/// Encoding a <b>Picture</b> into the a file with fd with required format.
///
/// # Arguments
///
/// `imagePacker` - The imagePacker to use for packing.
///
/// `options` - Indicates the encoding [`OH_PackingOptions`].
///
/// `picture` - The picture to be packed.
///
/// `fd` - Indicates a writable file descriptor.
///
/// # Returns
///
/// Image functions result code.
/// [`IMAGE_SUCCESS`] if the execution is successful.
/// [`IMAGE_BAD_PARAMETER`] imagePacker is nullptr, or picture is nullptr, or fd is invalid.
/// [`IMAGE_ENCODE_FAILED`] encode failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImagePackerNative_PackToFileFromPicture(
imagePacker: *mut OH_ImagePackerNative,
options: *mut OH_PackingOptions,
picture: *mut OH_PictureNative,
fd: i32,
) -> Image_ErrorCode;
/// Releases an imagePacker object.
///
/// # Arguments
Expand Down
Loading

0 comments on commit e4f42e8

Please sign in to comment.