3 * Purpose: Jasper Image Class Loader and Writer
\r
5 /* ==========================================================
\r
6 * CxImageJAS (c) 12/Apr/2003 Davide Pizzolato - www.xdp.it
\r
7 * For conditions of distribution and use, see copyright notice in ximage.h
\r
9 * based on JasPer Copyright (c) 2001-2003 Michael David Adams - All rights reserved.
\r
10 * ==========================================================
\r
12 #if !defined(__ximaJAS_h)
\r
17 #if CXIMAGE_SUPPORT_JASPER
\r
19 #include "../jasper/include/jasper/jasper.h"
\r
21 class CxImageJAS: public CxImage
\r
24 CxImageJAS(): CxImage((DWORD)0) {} // <vho> cast to DWORD
\r
26 // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,0);}
\r
27 // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,0);}
\r
28 bool Decode(CxFile * hFile, DWORD imagetype = 0);
\r
29 bool Decode(FILE *hFile, DWORD imagetype = 0) { CxIOFile file(hFile); return Decode(&file,imagetype); }
\r
31 #if CXIMAGE_SUPPORT_ENCODE
\r
32 bool Encode(CxFile * hFile, DWORD imagetype = 0);
\r
33 bool Encode(FILE *hFile, DWORD imagetype = 0) { CxIOFile file(hFile); return Encode(&file,imagetype); }
\r
34 #endif // CXIMAGE_SUPPORT_ENCODE
\r
40 CxFileJas(CxFile* pFile,jas_stream_t *stream)
\r
42 if (stream->obj_) jas_free(stream->obj_);
\r
43 stream->obj_ = pFile;
\r
45 // <vho> - cannot set the stream->ops_->functions here,
\r
46 // because this overwrites a static structure in the Jasper library.
\r
47 // This structure is used by Jasper for internal operations too, e.g. tempfile.
\r
48 // However the ops_ pointer in the stream can be overwritten.
\r
50 //stream->ops_->close_ = JasClose;
\r
51 //stream->ops_->read_ = JasRead;
\r
52 //stream->ops_->seek_ = JasSeek;
\r
53 //stream->ops_->write_ = JasWrite;
\r
55 jas_stream_CxFile.close_ = JasClose;
\r
56 jas_stream_CxFile.read_ = JasRead;
\r
57 jas_stream_CxFile.seek_ = JasSeek;
\r
58 jas_stream_CxFile.write_ = JasWrite;
\r
60 stream->ops_ = &jas_stream_CxFile;
\r
64 static int JasRead(jas_stream_obj_t *obj, char *buf, int cnt)
\r
65 { return ((CxFile*)obj)->Read(buf,1,cnt); }
\r
66 static int JasWrite(jas_stream_obj_t *obj, char *buf, int cnt)
\r
67 { return ((CxFile*)obj)->Write(buf,1,cnt); }
\r
68 static long JasSeek(jas_stream_obj_t *obj, long offset, int origin)
\r
69 { return ((CxFile*)obj)->Seek(offset,origin); }
\r
70 static int JasClose(jas_stream_obj_t * /*obj*/)
\r
75 jas_stream_ops_t jas_stream_CxFile;
\r