From 069deb1cf063d82a10cfdb1953b8da600fe5aea2 Mon Sep 17 00:00:00 2001 From: yjx Date: Sat, 23 Mar 2024 09:36:49 +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: I9f985b6ccdb9b00074c71129bab249182170cff5 --- graphic/graphic_2d/native_drawing/BUILD.gn | 2 + .../native_drawing/drawing_canvas.h | 15 ++++ .../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, 101 insertions(+) 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 542a4865597..493714389d5 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 521c93ec67a..a499aaae36b 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 00000000000..2203d9fd236 --- /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 1d544bec9a0..f4f7db452f3 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 4279a87c253..c9e077bd669 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" }, -- Gitee