]> Creatis software - clitk.git/blob - utilities/CxImage/ximaraw.h
Correct bug to compute 2NotIn1
[clitk.git] / utilities / CxImage / ximaraw.h
1 /*\r
2  * File:        ximaraw.h\r
3  * Purpose:     RAW Image Class Loader and Writer\r
4  */\r
5 /* ==========================================================\r
6  * CxImageRAW (c) May/2006 pdw63\r
7  * For conditions of distribution and use, see copyright notice in ximage.h\r
8  * Special thanks to David Coffin for dcraw without which this class would not exist\r
9  *\r
10  * libdcr (c) Dec/2007 Davide Pizzolato - www.xdp.it\r
11  *\r
12  * based on dcraw.c -- Dave Coffin's raw photo decoder\r
13  * Copyright 1997-2007 by Dave Coffin, dcoffin a cybercom o net\r
14  * ==========================================================\r
15  */\r
16 #if !defined(__ximaRAW_h)\r
17 #define __ximaRAW_h\r
18 \r
19 #include "ximage.h"\r
20 \r
21 #if CXIMAGE_SUPPORT_RAW\r
22 \r
23 extern "C" {\r
24  #include "../raw/libdcr.h"\r
25 }\r
26 \r
27 class CxImageRAW: public CxImage\r
28 {\r
29 \r
30 public:\r
31         CxImageRAW(): CxImage(CXIMAGE_FORMAT_RAW) {}\r
32 \r
33 //      bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_ICO);}\r
34 //      bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_ICO);}\r
35         bool Decode(CxFile * hFile);\r
36         bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }\r
37 \r
38 #if CXIMAGE_SUPPORT_ENCODE\r
39         bool Encode(CxFile * hFile);\r
40         bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); }\r
41 #endif // CXIMAGE_SUPPORT_ENCODE\r
42 \r
43         enum CODEC_OPTION\r
44         {\r
45                 DECODE_QUALITY_LIN = 0x00,\r
46                 DECODE_QUALITY_VNG = 0x01,\r
47                 DECODE_QUALITY_PPG = 0x02,\r
48                 DECODE_QUALITY_AHD = 0x03,\r
49         }; \r
50 \r
51 protected:\r
52 \r
53         class CxFileRaw\r
54         {\r
55         public:\r
56                 CxFileRaw(CxFile* pFile,DCRAW *stream)\r
57                 {\r
58                         stream->obj_ = pFile;\r
59 \r
60                         ras_stream_CxFile.read_ = raw_sfile_read;\r
61                         ras_stream_CxFile.write_ = raw_sfile_write;\r
62                         ras_stream_CxFile.seek_ = raw_sfile_seek;\r
63                         ras_stream_CxFile.close_ = raw_sfile_close;\r
64                         ras_stream_CxFile.gets_ = raw_sfile_gets;\r
65                         ras_stream_CxFile.eof_ = raw_sfile_eof;\r
66                         ras_stream_CxFile.tell_ = raw_sfile_tell;\r
67                         ras_stream_CxFile.getc_ = raw_sfile_getc;\r
68                         ras_stream_CxFile.scanf_ = raw_sfile_scanf;\r
69 \r
70                         stream->ops_ = &ras_stream_CxFile;\r
71 \r
72                 }\r
73 \r
74                 static int raw_sfile_read(dcr_stream_obj *obj, void *buf, int size, int cnt)\r
75                 {       return ((CxFile*)obj)->Read(buf,size,cnt); }\r
76 \r
77                 static int raw_sfile_write(dcr_stream_obj *obj, void *buf, int size, int cnt)\r
78                 {       return ((CxFile*)obj)->Write(buf,size,cnt); }\r
79 \r
80                 static long raw_sfile_seek(dcr_stream_obj *obj, long offset, int origin)\r
81                 {       return ((CxFile*)obj)->Seek(offset,origin); }\r
82 \r
83                 static int raw_sfile_close(dcr_stream_obj *obj)\r
84                 {       return 1; /*((CxFile*)obj)->Close();*/ }\r
85 \r
86                 static char* raw_sfile_gets(dcr_stream_obj *obj, char *string, int n)\r
87                 {       return ((CxFile*)obj)->GetS(string,n); }\r
88 \r
89                 static int   raw_sfile_eof(dcr_stream_obj *obj)\r
90                 {       return ((CxFile*)obj)->Eof(); }\r
91 \r
92                 static long  raw_sfile_tell(dcr_stream_obj *obj)\r
93                 {       return ((CxFile*)obj)->Tell(); }\r
94 \r
95                 static int   raw_sfile_getc(dcr_stream_obj *obj)\r
96                 {       return ((CxFile*)obj)->GetC(); }\r
97 \r
98                 static int   raw_sfile_scanf(dcr_stream_obj *obj,const char *format, void* output)\r
99                 {       return ((CxFile*)obj)->Scanf(format, output); }\r
100 \r
101         private:\r
102                 dcr_stream_ops ras_stream_CxFile;\r
103         };\r
104 };\r
105 \r
106 #endif\r
107 \r
108 #endif\r