diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index 60e24af8d5234c31a2686e65ddefe17bc0c129ed..b1e577748174a9c4ca2dc9eaa91a082cec54161b 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -32,6 +32,7 @@ ohos_ndk_headers("native_drawing_header") { "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_path.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_path_effect.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pen.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pixel_map.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_point.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_rect.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_register_font.h", @@ -66,6 +67,7 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_path.h", "native_drawing/drawing_path_effect.h", "native_drawing/drawing_pen.h", + "native_drawing/drawing_pixel_map.h", "native_drawing/drawing_point.h", "native_drawing/drawing_rect.h", "native_drawing/drawing_register_font.h", diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index c65f1a8130485d159e57cc6419cdb826cc0b0b91..622f2559b4c08d46ca8e8afebbe0b2827421e898 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -199,6 +199,21 @@ void OH_Drawing_CanvasDrawLine(OH_Drawing_Canvas*, float x1, float y1, float x2, */ void OH_Drawing_CanvasDrawPath(OH_Drawing_Canvas*, const OH_Drawing_Path*); +/** + * @brief Draw the specified area of the Media::PixelMap 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_PixelMap Indicates the pointer to an OH_Drawing_PixelMap object. + * @param src the area of source pixelmap. + * @param dst the area of destination canvas. + * @param OH_Drawing_SamplingOptions the sampling mode. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_CanvasDrawPixelMapRect(OH_Drawing_Canvas*, OH_Drawing_PixelMap*, const OH_Drawing_Rect* src, + const OH_Drawing_Rect* dst, const OH_Drawing_SamplingOptions*); + /** * @brief Draws a bitmap. * diff --git a/graphic/graphic_2d/native_drawing/drawing_pixel_map.h b/graphic/graphic_2d/native_drawing/drawing_pixel_map.h new file mode 100644 index 0000000000000000000000000000000000000000..2203d9fd23694d89a2bbe86414ddb2a92cbb8e76 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_pixel_map.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_PIXEL_MAP_H +#define C_INCLUDE_DRAWING_PIXEL_MAP_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_pixel_map.h + * + * @brief Declares functions related to the pixelmap object in the drawing module. + * + * @since 12 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Introduces the native pixel map information defined by image framework. + * @since 12 + * @version 1.0 + */ +struct NativePixelMap_; + +/** + * @brief Gets an OH_Drawing_PixelMap object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param NativePixelMap_ Indicates a pointer to an native pixelmap supported by image framework. + * @return Returns the pointer to the OH_Drawing_PixelMap object. + * @since 12 + * @version 1.0 + */ +OH_Drawing_PixelMap* OH_Drawing_PixelMapGetFromNativePixelMap(NativePixelMap_*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index 23e50f38dc3175744df726236a0011a5715abcec..2d3c4c2192615e85efa9e10dfd0861f148f531e2 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -93,6 +93,14 @@ typedef struct OH_Drawing_Bitmap OH_Drawing_Bitmap; */ typedef struct OH_Drawing_Point OH_Drawing_Point; +/** + * @brief Defines a pixelmap, which is used to wrap real pixelmap supported by image framework. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_PixelMap OH_Drawing_PixelMap; + /** * @brief Defines a point of 2d. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index d8586b349e19d12808e182919e7b24210e30abde..baac54aed2b7c0c099998d7eac58297831c5c397 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -48,6 +48,10 @@ { "name": "OH_Drawing_CanvasDrawLine" }, { "name": "OH_Drawing_CanvasDrawOval" }, { "name": "OH_Drawing_CanvasDrawPath" }, + { + "first_introduced": "12", + "name": "OH_Drawing_CanvasDrawPixelMapRect" + }, { "name": "OH_Drawing_CanvasDrawRect" }, { "name": "OH_Drawing_CanvasDrawRoundRect" }, { "name": "OH_Drawing_CanvasDrawTextBlob" }, @@ -211,6 +215,10 @@ { "name": "OH_Drawing_TypographyGetMaxIntrinsicWidth" }, { "name": "OH_Drawing_TypographyGetAlphabeticBaseline" }, { "name": "OH_Drawing_TypographyGetIdeographicBaseline" }, + { + "first_introduced": "12", + "name": "OH_Drawing_PixelMapGetFromNativePixelMap" + }, { "name": "OH_Drawing_ImageCreate" }, { "name": "OH_Drawing_ImageDestroy" }, { "name": "OH_Drawing_ImageBuildFromBitmap" },