jfifcontainer.h

00001 /*
00002  * libopenraw - jfifcontainer.h
00003  *
00004  * Copyright (C) 2006 Hubert Figuiere
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 
00022 
00028 #ifndef _JFIFCONTAINER_H_
00029 #define _JFIFCONTAINER_H_
00030 
00031 #include <setjmp.h>
00032 #include <cstdio>
00033 
00034 namespace JPEG {
00035 #include <jpeglib.h>
00036 }
00037 
00038 #include <libopenraw/types.h>
00039 #include <libopenraw/consts.h>
00040 
00041 #include "exception.h"
00042 #include "rawcontainer.h"
00043 
00044 namespace OpenRaw {
00045 
00046     namespace Internals {
00047 
00048         class JFIFContainer
00049             : public RawContainer
00050         {
00051         public:
00052             JFIFContainer(IO::Stream *file, off_t offset);
00054             virtual ~JFIFContainer();
00055 
00056             bool getDimensions(uint32_t &x, uint32_t &y);
00057 
00058             /* libjpeg callbacks j_ is the prefix for these callbacks */
00059             static void j_init_source(JPEG::j_decompress_ptr cinfo);
00060             static JPEG::boolean j_fill_input_buffer(JPEG::j_decompress_ptr cinfo);
00061             static void j_skip_input_data(JPEG::j_decompress_ptr cinfo, 
00062                                                                         long num_bytes);
00063 //          static void j_jpeg_resync_to_restart(JPEG::j_decompress_ptr cinfo);
00064             static void j_term_source(JPEG::j_decompress_ptr cinfo);
00065             static void j_error_exit(JPEG::j_common_ptr cinfo);
00066 
00067         private:
00068           int _loadHeader();
00069 
00070             struct JPEG::jpeg_decompress_struct m_cinfo;
00071             struct JPEG::jpeg_error_mgr m_jerr;
00072             jmp_buf m_jpegjmp;
00073             bool m_headerLoaded;
00074         };
00075 
00076     }
00077 }
00078 
00079 #endif

Generated on Sat Jan 27 11:36:13 2007 for libopenraw by  doxygen 1.4.7