3 * Purpose: RAW Image Class Loader and Writer
\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
10 * libdcr (c) Dec/2007 Davide Pizzolato - www.xdp.it
\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
16 #if !defined(__ximaRAW_h)
\r
21 #if CXIMAGE_SUPPORT_RAW
\r
24 #include "../raw/libdcr.h"
\r
27 class CxImageRAW: public CxImage
\r
31 CxImageRAW(): CxImage(CXIMAGE_FORMAT_RAW) {}
\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
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
45 DECODE_QUALITY_LIN = 0x00,
\r
46 DECODE_QUALITY_VNG = 0x01,
\r
47 DECODE_QUALITY_PPG = 0x02,
\r
48 DECODE_QUALITY_AHD = 0x03,
\r
56 CxFileRaw(CxFile* pFile,DCRAW *stream)
\r
58 stream->obj_ = pFile;
\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
70 stream->ops_ = &ras_stream_CxFile;
\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
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
80 static long raw_sfile_seek(dcr_stream_obj *obj, long offset, int origin)
\r
81 { return ((CxFile*)obj)->Seek(offset,origin); }
\r
83 static int raw_sfile_close(dcr_stream_obj *obj)
\r
84 { return 1; /*((CxFile*)obj)->Close();*/ }
\r
86 static char* raw_sfile_gets(dcr_stream_obj *obj, char *string, int n)
\r
87 { return ((CxFile*)obj)->GetS(string,n); }
\r
89 static int raw_sfile_eof(dcr_stream_obj *obj)
\r
90 { return ((CxFile*)obj)->Eof(); }
\r
92 static long raw_sfile_tell(dcr_stream_obj *obj)
\r
93 { return ((CxFile*)obj)->Tell(); }
\r
95 static int raw_sfile_getc(dcr_stream_obj *obj)
\r
96 { return ((CxFile*)obj)->GetC(); }
\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
102 dcr_stream_ops ras_stream_CxFile;
\r