image.h (2449B)
1/** 2 * WinPR: Windows Portable Runtime 3 * Image Utils 4 * 5 * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 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 28struct _WINPR_BITMAP_FILE_HEADER 29{ 30 BYTE bfType[2]; 31 UINT32 bfSize; 32 UINT16 bfReserved1; 33 UINT16 bfReserved2; 34 UINT32 bfOffBits; 35}; 36typedef struct _WINPR_BITMAP_FILE_HEADER WINPR_BITMAP_FILE_HEADER; 37 38struct _WINPR_BITMAP_INFO_HEADER 39{ 40 UINT32 biSize; 41 INT32 biWidth; 42 INT32 biHeight; 43 UINT16 biPlanes; 44 UINT16 biBitCount; 45 UINT32 biCompression; 46 UINT32 biSizeImage; 47 INT32 biXPelsPerMeter; 48 INT32 biYPelsPerMeter; 49 UINT32 biClrUsed; 50 UINT32 biClrImportant; 51}; 52typedef struct _WINPR_BITMAP_INFO_HEADER WINPR_BITMAP_INFO_HEADER; 53 54struct _WINPR_BITMAP_CORE_HEADER 55{ 56 UINT32 bcSize; 57 UINT16 bcWidth; 58 UINT16 bcHeight; 59 UINT16 bcPlanes; 60 UINT16 bcBitCount; 61}; 62typedef struct _WINPR_BITMAP_CORE_HEADER WINPR_BITMAP_CORE_HEADER; 63 64#pragma pack(pop) 65 66#define WINPR_IMAGE_BITMAP 0 67#define WINPR_IMAGE_PNG 1 68 69#define WINPR_IMAGE_BMP_HEADER_LEN 54 70 71struct _wImage 72{ 73 int type; 74 int width; 75 int height; 76 BYTE* data; 77 int scanline; 78 int bitsPerPixel; 79 int bytesPerPixel; 80}; 81typedef struct _wImage wImage; 82 83#ifdef __cplusplus 84extern "C" 85{ 86#endif 87 88 WINPR_API int winpr_bitmap_write(const char* filename, const BYTE* data, int width, int height, 89 int bpp); 90 WINPR_API BYTE* winpr_bitmap_construct_header(int width, int height, int bpp); 91 92 WINPR_API int winpr_image_write(wImage* image, const char* filename); 93 WINPR_API int winpr_image_read(wImage* image, const char* filename); 94 95 WINPR_API int winpr_image_read_buffer(wImage* image, const BYTE* buffer, int size); 96 97 WINPR_API wImage* winpr_image_new(); 98 WINPR_API void winpr_image_free(wImage* image, BOOL bFreeBuffer); 99 100#ifdef __cplusplus 101} 102#endif 103 104#endif /* WINPR_IMAGE_H */