FreeRDP
include/winpr/image.h
1 
20 #ifndef WINPR_IMAGE_H
21 #define WINPR_IMAGE_H
22 
23 #include <winpr/winpr.h>
24 #include <winpr/wtypes.h>
25 
26 #pragma pack(push, 1)
27 
28 typedef struct
29 {
30  BYTE bfType[2];
31  UINT32 bfSize;
32  UINT16 bfReserved1;
33  UINT16 bfReserved2;
34  UINT32 bfOffBits;
36 
37 typedef struct
38 {
39  UINT32 biSize;
40  INT32 biWidth;
41  INT32 biHeight;
42  UINT16 biPlanes;
43  UINT16 biBitCount;
44  UINT32 biCompression;
45  UINT32 biSizeImage;
46  INT32 biXPelsPerMeter;
47  INT32 biYPelsPerMeter;
48  UINT32 biClrUsed;
49  UINT32 biClrImportant;
51 
52 typedef struct
53 {
54  UINT32 bcSize;
55  UINT16 bcWidth;
56  UINT16 bcHeight;
57  UINT16 bcPlanes;
58  UINT16 bcBitCount;
60 
61 #pragma pack(pop)
62 
66 #define WINPR_IMAGE_BITMAP 0
67 #define WINPR_IMAGE_PNG 1
68 #define WINPR_IMAGE_JPEG 2
69 #define WINPR_IMAGE_WEBP 3
72 #define WINPR_IMAGE_BMP_HEADER_LEN 54
73 
74 typedef struct
75 {
76  int type;
77  UINT32 width;
78  UINT32 height;
79  BYTE* data;
80  UINT32 scanline;
81  UINT32 bitsPerPixel;
82  UINT32 bytesPerPixel;
83 } wImage;
84 
89 typedef enum
90 {
91  WINPR_IMAGE_CMP_NO_FLAGS = 0,
92  WINPR_IMAGE_CMP_IGNORE_DEPTH = 1,
93  WINPR_IMAGE_CMP_IGNORE_ALPHA = 2,
94  WINPR_IMAGE_CMP_FUZZY = 4
95 } wImageFlags;
96 
99 #ifdef __cplusplus
100 extern "C"
101 {
102 #endif
103 
104  WINPR_API int winpr_bitmap_write(const char* filename, const BYTE* data, size_t width,
105  size_t height, size_t bpp);
106 
120  WINPR_API int winpr_bitmap_write_ex(const char* filename, const BYTE* data, size_t stride,
121  size_t width, size_t height, size_t bpp);
122  WINPR_API BYTE* winpr_bitmap_construct_header(size_t width, size_t height, size_t bpp);
123 
124  WINPR_API int winpr_image_write(wImage* image, const char* filename);
125  WINPR_API int winpr_image_write_ex(wImage* image, UINT32 format, const char* filename);
126  WINPR_API int winpr_image_read(wImage* image, const char* filename);
127 
139  WINPR_ATTR_MALLOC(free, 1)
140  WINPR_API void* winpr_image_write_buffer(wImage* image, UINT32 format, size_t* size);
141  WINPR_API int winpr_image_read_buffer(wImage* image, const BYTE* buffer, size_t size);
142 
143  WINPR_API void winpr_image_free(wImage* image, BOOL bFreeBuffer);
144 
145  WINPR_ATTR_MALLOC(winpr_image_free, 1)
146  WINPR_API wImage* winpr_image_new(void);
147 
156  WINPR_API BOOL winpr_image_format_is_supported(UINT32 format);
157 
166  WINPR_API const char* winpr_image_format_extension(UINT32 format);
167 
176  WINPR_API const char* winpr_image_format_mime(UINT32 format);
177 
188  WINPR_API BOOL winpr_image_equal(const wImage* imageA, const wImage* imageB, UINT32 flags);
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* WINPR_IMAGE_H */