OSDN Git Service

first
[psychlops/cpp.git] / psychlops / extension / FileFormat / PNG / psychlops_g_PNG_bridge.h
1 /*
2  *  psychlops_g_PNG_bridge.h
3  *  Psychlops Standard Library (Universal)
4  *
5  *  Last Modified 2006/08/22 by Kenchi HOSOKAWA
6  *  (C) 2006- Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
7  */
8
9 #ifndef HEADER_PSYCHLOPS_IMAGE_FORMATS_PNG
10 #define HEADER_PSYCHLOPS_IMAGE_FORMATS_PNG
11
12 #ifndef __cplusplus
13 #define __cplusplus
14 #endif
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include "png.h"
19
20 #include "../../../core/graphic/psychlops_g_image.h"
21
22
23 namespace Psychlops {
24 namespace IMAGE_FORMATS {
25
26
27         const unsigned int PNG_BYTES_TO_CHECK = 4;
28         class PNG_BRIDGE : public IMAGE_FORMAT {
29                 private:
30                 FILE *fp;
31                 bool is_opened_;
32
33                 // PNG specific
34                 png_structp png_ptr;
35                 png_infop   info_ptr, end_info_ptr;
36                 png_uint_32 i;
37                 double      file_gamma;
38
39
40                 public:
41                 PNG_BRIDGE();
42                 virtual ~PNG_BRIDGE();
43                 virtual void load(const char *file_name, Image * target);
44                 virtual void save(const char *file_name, Image * target);
45
46                 private:
47                 void open(const char *file_name, const char *mode);
48                 void close();
49                 void check_before_read();
50                 void read(Image * target);
51                 void prepare_before_write();
52                 void write(Image * target);
53
54         };
55
56
57 }
58 }
59
60 #endif