1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef C_INCLUDE_DRAWING_BITMAP_H 17 #define C_INCLUDE_DRAWING_BITMAP_H 18 19 /** 20 * @addtogroup Drawing 21 * @{ 22 * 23 * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 24 * 25 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 26 * 27 * @since 8 28 * @version 1.0 29 */ 30 31 /** 32 * @file drawing_bitmap.h 33 * 34 * @brief Declares functions related to the <b>bitmap</b> object in the drawing module. 35 * 36 * @since 8 37 * @version 1.0 38 */ 39 40 #include "drawing_types.h" 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /** 47 * @brief Defines the pixel format of a bitmap, including the color type and alpha type. 48 * 49 * @since 8 50 * @version 1.0 51 */ 52 typedef struct { 53 /** Storage format of bitmap pixels */ 54 OH_Drawing_ColorFormat colorFormat; 55 /** Alpha format of bitmap pixels */ 56 OH_Drawing_AlphaFormat alphaFormat; 57 } OH_Drawing_BitmapFormat; 58 59 /** 60 * @brief Creates an <b>OH_Drawing_Bitmap</b> object. 61 * 62 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 63 * @return Returns the pointer to the <b>OH_Drawing_Bitmap</b> object created. 64 * @since 8 65 * @version 1.0 66 */ 67 OH_Drawing_Bitmap* OH_Drawing_BitmapCreate(void); 68 69 /** 70 * @brief Destroys an <b>OH_Drawing_Bitmap</b> object and reclaims the memory occupied by the object. 71 * 72 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 73 * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 74 * @since 8 75 * @version 1.0 76 */ 77 void OH_Drawing_BitmapDestroy(OH_Drawing_Bitmap*); 78 79 /** 80 * @brief Initializes the width and height of an <b>OH_Drawing_Bitmap</b> object 81 * and sets the pixel format for the bitmap. 82 * 83 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 84 * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 85 * @param width Indicates the width of the bitmap to be initialized. 86 * @param height Indicates the height of the bitmap to be initialized. 87 * @param OH_Drawing_BitmapFormat Indicates the pixel format of the bitmap to be initialized, 88 * including the pixel color type and alpha type. 89 * @since 8 90 * @version 1.0 91 */ 92 void OH_Drawing_BitmapBuild( 93 OH_Drawing_Bitmap*, const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat*); 94 95 /** 96 * @brief Obtains the width of a bitmap. 97 * 98 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 99 * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 100 * @return Returns the width. 101 * @since 8 102 * @version 1.0 103 */ 104 uint32_t OH_Drawing_BitmapGetWidth(OH_Drawing_Bitmap*); 105 106 /** 107 * @brief Obtains the height of a bitmap. 108 * 109 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 110 * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 111 * @return Returns the height. 112 * @since 8 113 * @version 1.0 114 */ 115 uint32_t OH_Drawing_BitmapGetHeight(OH_Drawing_Bitmap*); 116 117 /** 118 * @brief Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. 119 * 120 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 121 * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object. 122 * @return Returns the pixel address. 123 * @since 8 124 * @version 1.0 125 */ 126 void* OH_Drawing_BitmapGetPixels(OH_Drawing_Bitmap*); 127 128 #ifdef __cplusplus 129 } 130 #endif 131 /** @} */ 132 #endif 133