From 89560c99a162d73332f70a9c66b9e501e989e6a6 Mon Sep 17 00:00:00 2001 From: yjx Date: Mon, 18 Mar 2024 18:32:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0DrawPixelMap=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=8A=E7=9B=B8=E5=85=B3=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yjx Change-Id: I76b585b576b755d7d279b1c6895a245eddd806e6 --- graphic/graphic_2d/native_drawing/BUILD.gn | 2 + .../native_drawing/drawing_canvas.h | 17 ++++- .../native_drawing/drawing_pixel_map.h | 68 +++++++++++++++++++ .../graphic_2d/native_drawing/drawing_types.h | 8 +++ .../native_drawing/libnative_drawing.ndk.json | 8 +++ 5 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 graphic/graphic_2d/native_drawing/drawing_pixel_map.h diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index 60e24af8d..b1e577748 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 c65f1a813..622f2559b 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 000000000..2203d9fd2 --- /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 23e50f38d..2d3c4c219 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 d8586b349..baac54aed 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" }, -- Gitee