17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#ifndef C_INCLUDE_DRAWING_BITMAP_H 177777dab0Sopenharmony_ci#define C_INCLUDE_DRAWING_BITMAP_H 187777dab0Sopenharmony_ci 197777dab0Sopenharmony_ci/** 207777dab0Sopenharmony_ci * @addtogroup Drawing 217777dab0Sopenharmony_ci * @{ 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 247777dab0Sopenharmony_ci * 257777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 267777dab0Sopenharmony_ci * 277777dab0Sopenharmony_ci * @since 8 287777dab0Sopenharmony_ci * @version 1.0 297777dab0Sopenharmony_ci */ 307777dab0Sopenharmony_ci 317777dab0Sopenharmony_ci/** 327777dab0Sopenharmony_ci * @file drawing_bitmap.h 337777dab0Sopenharmony_ci * 347777dab0Sopenharmony_ci * @brief Declares functions related to the <b>bitmap</b> object in the drawing module. 357777dab0Sopenharmony_ci * 367777dab0Sopenharmony_ci * @kit ArkGraphics2D 377777dab0Sopenharmony_ci * @library libnative_drawing.so 387777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 397777dab0Sopenharmony_ci * @since 8 407777dab0Sopenharmony_ci * @version 1.0 417777dab0Sopenharmony_ci */ 427777dab0Sopenharmony_ci 437777dab0Sopenharmony_ci#include "drawing_types.h" 447777dab0Sopenharmony_ci 457777dab0Sopenharmony_ci#ifdef __cplusplus 467777dab0Sopenharmony_ciextern "C" { 477777dab0Sopenharmony_ci#endif 487777dab0Sopenharmony_ci 497777dab0Sopenharmony_ci/** 507777dab0Sopenharmony_ci * @brief Defines the pixel format of a bitmap, including the color type and alpha type. 517777dab0Sopenharmony_ci * 527777dab0Sopenharmony_ci * @since 8 537777dab0Sopenharmony_ci * @version 1.0 547777dab0Sopenharmony_ci */ 557777dab0Sopenharmony_citypedef struct { 567777dab0Sopenharmony_ci /** Storage format of bitmap pixels */ 577777dab0Sopenharmony_ci OH_Drawing_ColorFormat colorFormat; 587777dab0Sopenharmony_ci /** Alpha format of bitmap pixels */ 597777dab0Sopenharmony_ci OH_Drawing_AlphaFormat alphaFormat; 607777dab0Sopenharmony_ci} OH_Drawing_BitmapFormat; 617777dab0Sopenharmony_ci 627777dab0Sopenharmony_ci/** 637777dab0Sopenharmony_ci * @brief Creates an <b>OH_Drawing_Bitmap</b> object. 647777dab0Sopenharmony_ci * 657777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 667777dab0Sopenharmony_ci * @return Returns the pointer to the <b>OH_Drawing_Bitmap</b> object created. 677777dab0Sopenharmony_ci * @since 8 687777dab0Sopenharmony_ci * @version 1.0 697777dab0Sopenharmony_ci */ 707777dab0Sopenharmony_ciOH_Drawing_Bitmap* OH_Drawing_BitmapCreate(void); 717777dab0Sopenharmony_ci 727777dab0Sopenharmony_ci/** 737777dab0Sopenharmony_ci * @brief Destroys an <b>OH_Drawing_Bitmap</b> object and reclaims the memory occupied by the object. 747777dab0Sopenharmony_ci * 757777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 767777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 777777dab0Sopenharmony_ci * @since 8 787777dab0Sopenharmony_ci * @version 1.0 797777dab0Sopenharmony_ci */ 807777dab0Sopenharmony_civoid OH_Drawing_BitmapDestroy(OH_Drawing_Bitmap*); 817777dab0Sopenharmony_ci 827777dab0Sopenharmony_ci/** 837777dab0Sopenharmony_ci * @brief Creates an <b>OH_Drawing_Bitmap</b> object with <b>OH_Drawing_Image_Info</b> object 847777dab0Sopenharmony_ci * and sets the mem address or pixel storage. 857777dab0Sopenharmony_ci * 867777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 877777dab0Sopenharmony_ci * @param OH_Drawing_Image_Info Indicates the pointer to an <b>OH_Drawing_Image_Info</b> object. 887777dab0Sopenharmony_ci * @param pixels the pointer to memory address or pixel storage. 897777dab0Sopenharmony_ci * @param rowBytes size of pixel row or larger. 907777dab0Sopenharmony_ci * @return Returns the pointer to the <b>OH_Drawing_Bitmap</b> object created. 917777dab0Sopenharmony_ci * @since 12 927777dab0Sopenharmony_ci * @version 1.0 937777dab0Sopenharmony_ci */ 947777dab0Sopenharmony_ciOH_Drawing_Bitmap* OH_Drawing_BitmapCreateFromPixels(OH_Drawing_Image_Info*, void* pixels, uint32_t rowBytes); 957777dab0Sopenharmony_ci 967777dab0Sopenharmony_ci/** 977777dab0Sopenharmony_ci * @brief Initializes the width and height of an <b>OH_Drawing_Bitmap</b> object 987777dab0Sopenharmony_ci * and sets the pixel format for the bitmap. 997777dab0Sopenharmony_ci * 1007777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1017777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 1027777dab0Sopenharmony_ci * @param width Indicates the width of the bitmap to be initialized. 1037777dab0Sopenharmony_ci * @param height Indicates the height of the bitmap to be initialized. 1047777dab0Sopenharmony_ci * @param OH_Drawing_BitmapFormat Indicates the pixel format of the bitmap to be initialized, 1057777dab0Sopenharmony_ci * including the pixel color type and alpha type. 1067777dab0Sopenharmony_ci * @since 8 1077777dab0Sopenharmony_ci * @version 1.0 1087777dab0Sopenharmony_ci */ 1097777dab0Sopenharmony_civoid OH_Drawing_BitmapBuild( 1107777dab0Sopenharmony_ci OH_Drawing_Bitmap*, const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat*); 1117777dab0Sopenharmony_ci 1127777dab0Sopenharmony_ci/** 1137777dab0Sopenharmony_ci * @brief Obtains the width of a bitmap. 1147777dab0Sopenharmony_ci * 1157777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1167777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 1177777dab0Sopenharmony_ci * @return Returns the width. 1187777dab0Sopenharmony_ci * @since 8 1197777dab0Sopenharmony_ci * @version 1.0 1207777dab0Sopenharmony_ci */ 1217777dab0Sopenharmony_ciuint32_t OH_Drawing_BitmapGetWidth(OH_Drawing_Bitmap*); 1227777dab0Sopenharmony_ci 1237777dab0Sopenharmony_ci/** 1247777dab0Sopenharmony_ci * @brief Obtains the height of a bitmap. 1257777dab0Sopenharmony_ci * 1267777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1277777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 1287777dab0Sopenharmony_ci * @return Returns the height. 1297777dab0Sopenharmony_ci * @since 8 1307777dab0Sopenharmony_ci * @version 1.0 1317777dab0Sopenharmony_ci */ 1327777dab0Sopenharmony_ciuint32_t OH_Drawing_BitmapGetHeight(OH_Drawing_Bitmap*); 1337777dab0Sopenharmony_ci 1347777dab0Sopenharmony_ci/** 1357777dab0Sopenharmony_ci * @brief Obtains the color format of a bitmap. 1367777dab0Sopenharmony_ci * 1377777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1387777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 1397777dab0Sopenharmony_ci * @return Returns the bitmap color format. 1407777dab0Sopenharmony_ci * @since 12 1417777dab0Sopenharmony_ci * @version 1.0 1427777dab0Sopenharmony_ci */ 1437777dab0Sopenharmony_ciOH_Drawing_ColorFormat OH_Drawing_BitmapGetColorFormat(OH_Drawing_Bitmap*); 1447777dab0Sopenharmony_ci 1457777dab0Sopenharmony_ci/** 1467777dab0Sopenharmony_ci * @brief Obtains the alpha format of a bitmap. 1477777dab0Sopenharmony_ci * 1487777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1497777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 1507777dab0Sopenharmony_ci * @return Returns the bitmap alpha format. 1517777dab0Sopenharmony_ci * @since 12 1527777dab0Sopenharmony_ci * @version 1.0 1537777dab0Sopenharmony_ci */ 1547777dab0Sopenharmony_ciOH_Drawing_AlphaFormat OH_Drawing_BitmapGetAlphaFormat(OH_Drawing_Bitmap*); 1557777dab0Sopenharmony_ci 1567777dab0Sopenharmony_ci/** 1577777dab0Sopenharmony_ci * @brief Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. 1587777dab0Sopenharmony_ci * 1597777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1607777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 1617777dab0Sopenharmony_ci * @return Returns the pixel address. 1627777dab0Sopenharmony_ci * @since 8 1637777dab0Sopenharmony_ci * @version 1.0 1647777dab0Sopenharmony_ci */ 1657777dab0Sopenharmony_civoid* OH_Drawing_BitmapGetPixels(OH_Drawing_Bitmap*); 1667777dab0Sopenharmony_ci 1677777dab0Sopenharmony_ci/** 1687777dab0Sopenharmony_ci * @brief Gets the image info. 1697777dab0Sopenharmony_ci * 1707777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1717777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 1727777dab0Sopenharmony_ci * @param OH_Drawing_Image_Info Indicates the pointer to an <b>OH_Drawing_Image_Info</b> object. 1737777dab0Sopenharmony_ci * @since 12 1747777dab0Sopenharmony_ci * @version 1.0 1757777dab0Sopenharmony_ci */ 1767777dab0Sopenharmony_civoid OH_Drawing_BitmapGetImageInfo(OH_Drawing_Bitmap*, OH_Drawing_Image_Info*); 1777777dab0Sopenharmony_ci 1787777dab0Sopenharmony_ci/** 1797777dab0Sopenharmony_ci * @brief Copies a rect of pixels from bitmap to dstPixels. Copy starts at (srcX, srcY), 1807777dab0Sopenharmony_ci * and does not exceed bitmap width and height. 1817777dab0Sopenharmony_ci * 1827777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1837777dab0Sopenharmony_ci * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 1847777dab0Sopenharmony_ci * @param dstInfo Indicates the pointer to an <b>OH_Drawing_Image_Info</b> object. 1857777dab0Sopenharmony_ci * @param dstPixels Destination pixel storage. 1867777dab0Sopenharmony_ci * @param dstRowBytes Destination row length. 1877777dab0Sopenharmony_ci * @param srcX Column index whose absolute value is less than width. 1887777dab0Sopenharmony_ci * @param srcY Row index whose absolute value is less than height. 1897777dab0Sopenharmony_ci * @return Returns true if pixels are copied to dstPixels. 1907777dab0Sopenharmony_ci * @since 12 1917777dab0Sopenharmony_ci * @version 1.0 1927777dab0Sopenharmony_ci */ 1937777dab0Sopenharmony_cibool OH_Drawing_BitmapReadPixels(OH_Drawing_Bitmap*, const OH_Drawing_Image_Info* dstInfo, 1947777dab0Sopenharmony_ci void* dstPixels, size_t dstRowBytes, int32_t srcX, int32_t srcY); 1957777dab0Sopenharmony_ci#ifdef __cplusplus 1967777dab0Sopenharmony_ci} 1977777dab0Sopenharmony_ci#endif 1987777dab0Sopenharmony_ci/** @} */ 1997777dab0Sopenharmony_ci#endif 200