1 /* 2 * Copyright (c) 2021 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 LOAD_BMP_H 17 #define LOAD_BMP_H 18 #include <stdint.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #define EIGHT_BITS_PER_PIXEL 8 25 #define INVALID_BITS 2 26 #define ONE_OFFSET 1 27 #define TWO_OFFSET 2 28 29 #define TWO_BITS_PER_PIXEL 2 30 #define THREE_BITS_PER_PIXEL 3 31 #define FOUR_BITS_PER_PIXEL 4 32 33 #define BITMAP_FILE 0x4d42 34 35 /* the color format OSD supported */ 36 typedef enum { 37 OSD_COLOR_FMT_RGB444 = 0, 38 OSD_COLOR_FMT_RGB4444 = 1, 39 OSD_COLOR_FMT_RGB555 = 2, 40 OSD_COLOR_FMT_RGB565 = 3, 41 OSD_COLOR_FMT_RGB1555 = 4, 42 OSD_COLOR_FMT_RGB888 = 6, 43 OSD_COLOR_FMT_RGB8888 = 7, 44 OSD_COLOR_FMT_BUTT 45 } OsdColorFmt; 46 47 typedef struct { 48 OsdColorFmt colorFmt; /* color format */ 49 uint16_t height; /* operation height */ 50 uint16_t width; /* operation width */ 51 uint16_t stride; /* esurface stride */ 52 uint16_t reserved; 53 } OsdSurface; 54 55 typedef struct { 56 uint32_t width; /* out */ 57 uint32_t height; /* out */ 58 uint32_t stride; /* in */ 59 uint32_t len; /* picBuffer length */ 60 uint16_t bpp; /* bpp */ 61 uint8_t *picBuffer; /* in/out */ 62 } OsdLogo; 63 64 typedef struct { 65 uint16_t size; 66 uint32_t width; 67 uint32_t height; 68 uint16_t planes; 69 uint16_t bitCnt; 70 uint32_t compress; 71 uint32_t sizeImage; 72 uint32_t xPelsPerMeter; 73 uint32_t yPelsPerMeter; 74 uint32_t clrUsed; 75 uint32_t clrImp; 76 } OsdBitMapInfoHeader; 77 78 typedef struct { 79 uint32_t size; 80 uint16_t reserved1; 81 uint16_t reserved2; 82 uint32_t offBits; 83 } OsdBitMapFileHeader; 84 85 typedef struct { 86 uint8_t blue; 87 uint8_t green; 88 uint8_t red; 89 uint8_t reserved; 90 } OsdRgbQuad; 91 92 typedef struct { 93 OsdBitMapInfoHeader header; 94 OsdRgbQuad colors[1]; 95 } OsdBitMapInfo; 96 97 typedef struct { 98 uint8_t aLen; 99 uint8_t rLen; 100 uint8_t gLen; 101 uint8_t bLen; 102 } OsdCompInfo; 103 104 typedef struct { 105 uint8_t r; 106 uint8_t g; 107 uint8_t b; 108 } OsdColor; 109 110 int32_t GetBmpInfo(const int8_t *fileName, OsdBitMapFileHeader *bmpFileHeader, OsdBitMapInfo *bmpInfo); 111 int32_t CreateSurfaceByBitMap(const int8_t *fileName, OsdSurface *pstSurface, uint8_t *virAddr, uint32_t len); 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 #endif /* End of #ifndef LOAD_BMP_H */ 118