diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 8d882ecc4a4b6f1fcb6ebf0cb4e21214109c36bb..8fc57c03a98f86834fc8477207459ad7244e00f4 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -482,7 +482,7 @@ void OH_Drawing_CanvasClear(OH_Drawing_Canvas*, uint32_t color); * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. - * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. * @since 12 * @version 1.0 */ @@ -494,13 +494,31 @@ void OH_Drawing_CanvasSetMatrix(OH_Drawing_Canvas*, OH_Drawing_Matrix*); * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. - * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Image object. + * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object. * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object. * @param OH_Drawing_SamplingOptions Indicates the pointer to an OH_Drawing_SamplingOptions object. * @since 12 * @version 1.0 */ -void OH_Drawing_CanvasDrawImageRect(OH_Drawing_Canvas*, OH_Drawing_Image*, OH_Drawing_Rect* dst, OH_Drawing_SamplingOptions*); +void OH_Drawing_CanvasDrawImageRect(OH_Drawing_Canvas*, OH_Drawing_Image*, + OH_Drawing_Rect* dst, OH_Drawing_SamplingOptions*); + +/** + * @brief Read pixels data from canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Image_Info width, height, colorType, and alphaType of dstPixels. + * @param dstPixels destination pixel storage. + * @param dstRowBytes size of one row of pixels. + * @param srcX offset into canvas writable pixels on x-axis. + * @param srcY offset into canvas writable pixels on y-axis. + * @return true if pixels are copied to dstPixels. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_CanvasReadPixels(OH_Drawing_Canvas*, OH_Drawing_Image_Info*, + void* dstPixels, uint32_t dstRowBytes, int32_t srcX, int32_t srcY); /** * @brief Read pixels data to a bitmap from canvas. @@ -508,8 +526,8 @@ void OH_Drawing_CanvasDrawImageRect(OH_Drawing_Canvas*, OH_Drawing_Image*, OH_Dr * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. - * @param srcX offset into SkCanvas writable pixels on x-axis. - * @param srcY offset into SkCanvas writable pixels on y-axis. + * @param srcX offset into canvas writable pixels on x-axis. + * @param srcY offset into canvas writable pixels on y-axis. * @return true if pixels are copied to dstBitmap. * @since 12 * @version 1.0 diff --git a/graphic/graphic_2d/native_drawing/drawing_image.h b/graphic/graphic_2d/native_drawing/drawing_image.h index bf96b7b34b1ba1192e9f595252a5bb15e27f160b..ed2f1f4914cc0deb31957b99d3f4697ab851c061 100644 --- a/graphic/graphic_2d/native_drawing/drawing_image.h +++ b/graphic/graphic_2d/native_drawing/drawing_image.h @@ -97,6 +97,17 @@ int32_t OH_Drawing_ImageGetWidth(OH_Drawing_Image*); */ int32_t OH_Drawing_ImageGetHeight(OH_Drawing_Image*); +/** + * @brief Gets the image info. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object. + * @param OH_Drawing_Image_Info Indicates the pointer to an OH_Drawing_Image_Info object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_ImageGetImageInfo(OH_Drawing_Image*, OH_Drawing_Image_Info*); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index f3d927d4eb1a2a1ca9ad39ffbabbf852b5d0062b..71a59ac76682371bb0339b9af960f7cb258d2e75 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -201,15 +201,15 @@ typedef struct OH_Drawing_TextBlob OH_Drawing_TextBlob; /** * @brief Defines a image, which is used to describe a two dimensional array of pixels to draw. * - * @since 11 + * @since 12 * @version 1.0 */ typedef struct OH_Drawing_Image OH_Drawing_Image; /** - * @brief Defines a matrix, which is used to describe the transforming coordinates. + * @brief Defines a sampling options, which is used to describe the sampling mode. * - * @since 11 + * @since 12 * @version 1.0 */ typedef struct OH_Drawing_SamplingOptions OH_Drawing_SamplingOptions; @@ -352,6 +352,23 @@ typedef enum { BLEND_MODE_LUMINOSITY, } OH_Drawing_BlendMode; +/** + * @brief Defines image info struct. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /** storage for width of image */ + int32_t width; + /** storage for height of image */ + int32_t height; + /** storage for color formats */ + OH_Drawing_ColorFormat colorType; + /** storage for alpha formats */ + OH_Drawing_AlphaFormat alphaType; +} OH_Drawing_Image_Info; + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 64d2dd988911ce65797d9989b54193e03838308d..1b6dbe76ded3fe3465e30cf04d27307f3e9fbac2 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -45,6 +45,7 @@ { "name": "OH_Drawing_CanvasClear" }, { "name": "OH_Drawing_CanvasSetMatrix" }, { "name": "OH_Drawing_CanvasDrawImageRect" }, + { "name": "OH_Drawing_CanvasReadPixels" }, { "name": "OH_Drawing_CanvasReadPixelsToBitmap" }, { "name": "OH_Drawing_CanvasGetWidth" }, { "name": "OH_Drawing_CanvasGetHeight" }, @@ -194,6 +195,7 @@ { "name": "OH_Drawing_ImageBuildFromBitmap" }, { "name": "OH_Drawing_ImageGetWidth" }, { "name": "OH_Drawing_ImageGetHeight" }, + { "name": "OH_Drawing_ImageGetImageInfo" }, { "name": "OH_Drawing_SamplingOptionsCreate" }, { "name": "OH_Drawing_SamplingOptionsDestroy" }, {