00001 #ifndef JPEGUTIL_H 00002 #define JPEGUTIL_H 00003 00004 #include "Image/Image.H" 00005 #include "Image/PixelsTypes.H" 00006 00007 #undef HAVE_STDLIB_H // needed on OSX 00008 00009 #include <jpeglib.h> 00010 #include <jerror.h> 00011 00012 class JPEGDecompressor 00013 { 00014 public: 00015 JPEGDecompressor(); 00016 00017 Image<PixRGB<byte> > DecompressImage(std::vector<unsigned char> &img_buffer); 00018 00019 private: 00020 00021 //Structure to hold all of our jpeg compression parameters 00022 struct jpeg_decompress_struct cinfo; 00023 00024 //Structure to handle all of our errors 00025 struct jpeg_error_mgr jerr; 00026 00027 GLOBAL(void) InitImageSource(std::vector<unsigned char>* source_buffer); 00028 }; 00029 00030 class JPEGCompressor 00031 { 00032 public: 00033 JPEGCompressor(); 00034 00035 std::vector<unsigned char> compressImage(Image<PixRGB<byte> >& input); 00036 00037 private: 00038 00039 //Structure to hold all of our jpeg compression parameters 00040 struct jpeg_compress_struct cinfo; 00041 00042 //Structure to handle all of our errors 00043 struct jpeg_error_mgr jerr; 00044 00045 GLOBAL(void) InitImageDest(std::vector<unsigned char>* destination_buffer); 00046 }; 00047 00048 #endif //JPEGUTIL_H 00049