diff --git a/graphic/graphic_2d/native_drawing/drawing_bitmap.h b/graphic/graphic_2d/native_drawing/drawing_bitmap.h index 52b0834123fda7b06909c9f715918b50611ea658..8a1304e91e51a378c8947310466924a8f2efc5c1 100644 --- a/graphic/graphic_2d/native_drawing/drawing_bitmap.h +++ b/graphic/graphic_2d/native_drawing/drawing_bitmap.h @@ -21,7 +21,7 @@ * @{ * * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. - * + * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * * @since 8 @@ -45,7 +45,7 @@ extern "C" { /** * @brief Defines the pixel format of a bitmap, including the color type and alpha type. - * + * * @since 8 * @version 1.0 */ @@ -76,6 +76,20 @@ OH_Drawing_Bitmap* OH_Drawing_BitmapCreate(void); */ void OH_Drawing_BitmapDestroy(OH_Drawing_Bitmap*); +/** + * @brief Creates an OH_Drawing_Bitmap object with OH_Drawing_Image_Info object + * and sets the mem address or pixel storage. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Image_Info Indicates the pointer to an OH_Drawing_Image_Info object. + * @param pixels the pointer to memory address or pixel storage. + * @param rowBytes size of pixel row or larger. + * @return Returns the pointer to the OH_Drawing_Bitmap object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Bitmap* OH_Drawing_BitmapCreateFromPixels(OH_Drawing_Image_Info*, void* pixels, uint32_t rowBytes); + /** * @brief Initializes the width and height of an OH_Drawing_Bitmap object * and sets the pixel format for the bitmap. diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 8d882ecc4a4b6f1fcb6ebf0cb4e21214109c36bb..2a1d23e394f924906d082218fbc2b891e90f614a 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -212,6 +212,21 @@ void OH_Drawing_CanvasDrawPath(OH_Drawing_Canvas*, const OH_Drawing_Path*); */ void OH_Drawing_CanvasDrawBitmap(OH_Drawing_Canvas*, const OH_Drawing_Bitmap*, float left, float top); +/** + * @brief Draw the specified area of the bitmap to the specified area of the canvas. + * + * @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 src the area of source bitmap, can be nullptr. + * @param dst the area of destination canvas. + * @param OH_Drawing_SamplingOptions the sampling mode. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_CanvasDrawBitmapRect(OH_Drawing_Canvas*, const OH_Drawing_Bitmap*, const OH_Drawing_Rect* src, + const OH_Drawing_Rect* dst, const OH_Drawing_SamplingOptions*); + /** * @brief Draws a rect. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 430200198f9871ce2542a642ba6b5e0a1da98b3f..a88ee894d5a382a28bf8535deb680bc1b4c94585 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -2,6 +2,7 @@ { "name": "OH_Drawing_BitmapCreate" }, { "name": "OH_Drawing_BitmapDestroy" }, { "name": "OH_Drawing_BitmapBuild" }, + { "name": "OH_Drawing_BitmapCreateFromPixels" }, { "name": "OH_Drawing_BitmapGetWidth" }, { "name": "OH_Drawing_BitmapGetHeight" }, { "name": "OH_Drawing_BitmapGetPixels" }, @@ -30,6 +31,7 @@ { "name": "OH_Drawing_CanvasRestoreToCount" }, { "name": "OH_Drawing_CanvasDrawArc" }, { "name": "OH_Drawing_CanvasDrawBitmap" }, + { "name": "OH_Drawing_CanvasDrawBitmapRect" }, { "name": "OH_Drawing_CanvasDrawCircle" }, { "name": "OH_Drawing_CanvasDrawLine" }, { "name": "OH_Drawing_CanvasDrawOval" },