diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index 542a4865597391104836ba8a98db1cea0d4c9fc8..493714389d583170be15b669eb4cfd18f066c806 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -33,6 +33,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_region.h", @@ -69,6 +70,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_region.h", diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 521c93ec67a1c08f5ea97b344bd52bc35e5b8930..a499aaae36b09c86883e898c200f7dd414f8874d 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -216,6 +216,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 Fills clipped canvas area with brush. * 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 1d544bec9a032f7488443baa697a118a4ddc5fd0..f4f7db452f365161769d6c36c27a57338a0c119c 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -109,6 +109,14 @@ typedef struct OH_Drawing_Point OH_Drawing_Point; */ typedef struct OH_Drawing_ColorSpace OH_Drawing_ColorSpace; +/** + * @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 4279a87c253f0d9d807fc7e76c6c48ca6bdc270b..c9e077bd6691de3bcd75ebc18e2750a055053e95 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -60,6 +60,10 @@ { "name": "OH_Drawing_CanvasDrawLine" }, { "name": "OH_Drawing_CanvasDrawOval" }, { "name": "OH_Drawing_CanvasDrawPath" }, + { + "first_introduced": "12", + "name": "OH_Drawing_CanvasDrawPixelMapRect" + }, { "first_introduced": "12", "name": "OH_Drawing_CanvasDrawPoints" @@ -415,6 +419,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" },