-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpngctrl.h
60 lines (42 loc) · 1.47 KB
/
pngctrl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
#pragma once
#ifndef _PNGCTRL_H_
#define _PNGCTRL_H_
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
//////////////////////////////////////////////////////////////////////////////////////////
#ifndef PDIB
typedef LPBITMAPINFOHEADER PDIB;
#endif
#define COLOR_TYPE_INDEX 0 // インデックスカラー
typedef struct {
unsigned char r; // Red
unsigned char g; // Green
unsigned char b; // Blue
unsigned char a; // Alpha
} color_t;
typedef struct
{
int width; // 幅
int height; // 高さ
unsigned short color_type; // 色表現の種別
unsigned short palette_num; // カラーパレットの数
color_t *palette; // カラーパレットへのポインタ
unsigned char ** map; // 画像データ
} IMAGEDATA;
#define DibPtr(lpbi) ((lpbi)->biCompression == BI_BITFIELDS \
? (LPVOID)(DibColors(lpbi) + 3) \
: (LPVOID)(DibColors(lpbi) + (UINT)(lpbi)->biClrUsed))
#define DibColors(lpbi) ((RGBQUAD FAR *)((LPBYTE)(lpbi) + (int)(lpbi)->biSize))
unsigned char** alloc_map(IMAGEDATA* img);
void free_map(IMAGEDATA* img);
int writepng(const char* filename, IMAGEDATA* img);
int write_png_stream(FILE* fp, IMAGEDATA* img);
PDIB pngptr2dib(void *pptr);
PDIB PngOpenFile(LPSTR szFile);
//////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _PNGCTRL_H_