source: liacs/MIR2010/SourceCode/cximage/ximaraw.h@ 140

Last change on this file since 140 was 95, checked in by Rick van der Zwet, 15 years ago

Bad boy, improper move of directory

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