home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / win32 / include / cximage / ximajas.h < prev    next >
C/C++ Source or Header  |  2004-02-29  |  3KB  |  80 lines

  1. /*
  2.  * File:    ximajas.h
  3.  * Purpose:    Jasper Image Class Loader and Writer
  4.  */
  5. /* === C R E D I T S  &  D I S C L A I M E R S ==============
  6.  * CxImageJAS (c) 12/Apr/2003 Davide Pizzolato - www.xdp.it
  7.  * Permission is given by the author to freely redistribute and include
  8.  * this code in any program as long as this credit is given where due.
  9.  *
  10.  * CxImage version 5.99a 08/Feb/2004
  11.  * See the file history.htm for the complete bugfix and news report.
  12.  *
  13.  * based on JasPer Copyright (c) 2001-2003 Michael David Adams - All rights reserved.
  14.  *
  15.  * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
  16.  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
  17.  * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
  18.  * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
  19.  * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
  20.  * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
  21.  * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
  22.  * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  23.  * THIS DISCLAIMER.
  24.  *
  25.  * Use at your own risk!
  26.  * ==========================================================
  27.  */
  28. #if !defined(__ximaJAS_h)
  29. #define __ximaJAS_h
  30.  
  31. #include "ximage.h"
  32.  
  33. #if CXIMAGE_SUPPORT_JASPER
  34.  
  35. #include "..\jasper\include\jasper\jasper.h"
  36.  
  37. class CxImageJAS: public CxImage
  38. {
  39. public:
  40.     CxImageJAS(): CxImage(0) {}
  41.  
  42. //    bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,0);}
  43. //    bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,0);}
  44.     bool Decode(CxFile * hFile, DWORD imagetype = 0);
  45.     bool Decode(FILE *hFile, DWORD imagetype = 0) { CxIOFile file(hFile); return Decode(&file,imagetype); }
  46.  
  47. #if CXIMAGE_SUPPORT_ENCODE
  48.     bool Encode(CxFile * hFile, DWORD imagetype = 0);
  49.     bool Encode(FILE *hFile, DWORD imagetype = 0) { CxIOFile file(hFile); return Encode(&file,imagetype); }
  50. #endif // CXIMAGE_SUPPORT_ENCODE
  51. protected:
  52.  
  53.     class CxFileJas
  54.     {
  55.     public:
  56.         CxFileJas(CxFile* pFile,jas_stream_t *stream)
  57.         {
  58.             if (stream->obj_) jas_free(stream->obj_);
  59.             stream->obj_ = pFile;
  60.             stream->ops_->close_ = JasClose;
  61.             stream->ops_->read_  = JasRead;
  62.             stream->ops_->seek_  = JasSeek;
  63.             stream->ops_->write_ = JasWrite;
  64.         }
  65.         static int JasRead(jas_stream_obj_t *obj, char *buf, int cnt)
  66.         {        return ((CxFile*)obj)->Read(buf,1,cnt); }
  67.         static int JasWrite(jas_stream_obj_t *obj, char *buf, int cnt)
  68.         {        return ((CxFile*)obj)->Write(buf,1,cnt); }
  69.         static long JasSeek(jas_stream_obj_t *obj, long offset, int origin)
  70.         {        return ((CxFile*)obj)->Seek(offset,origin); }
  71.         static int JasClose(jas_stream_obj_t *obj)
  72.         {        return 1; }
  73.     };
  74.  
  75. };
  76.  
  77. #endif
  78.  
  79. #endif
  80.