peffile.cpp

00001 /*
00002  * libopenraw - peffile.cpp
00003  *
00004  * Copyright (C) 2006-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00019  */
00020 
00021 
00022 #include <iostream>
00023 #include <libopenraw++/thumbnail.h>
00024 #include <libopenraw++/rawdata.h>
00025 
00026 #include "debug.h"
00027 #include "ifd.h"
00028 #include "ifdfilecontainer.h"
00029 #include "ifddir.h"
00030 #include "ifdentry.h"
00031 #include "io/file.h"
00032 #include "peffile.h"
00033 
00034 using namespace Debug;
00035 
00036 namespace OpenRaw {
00037 
00038 
00039     namespace Internals {
00040 
00041         RawFile *PEFFile::factory(const char* _filename)
00042         {
00043             return new PEFFile(_filename);
00044         }
00045 
00046         PEFFile::PEFFile(const char* _filename)
00047             : IFDFile(_filename, OR_RAWFILE_TYPE_PEF)
00048         {
00049         }
00050 
00051 
00052         PEFFile::~PEFFile()
00053         {
00054         }
00055 
00056         IFDDir::Ref  PEFFile::_locateCfaIfd()
00057         {
00058             // in PEF the CFA IFD is the main IFD
00059             if(!m_mainIfd) {
00060                 m_mainIfd = _locateMainIfd();
00061             }
00062             return m_mainIfd;
00063         }
00064 
00065 
00066         IFDDir::Ref  PEFFile::_locateMainIfd()
00067         {
00068             return m_container->setDirectory(0);
00069         }
00070 
00071         ::or_error PEFFile::_getRawData(RawData & data, uint32_t /*options*/)
00072         {
00073             ::or_error err;
00074             if(!m_cfaIfd) {
00075                 m_cfaIfd = _locateCfaIfd();
00076             }
00077             err = _getRawDataFromDir(data, m_cfaIfd);
00078             if(err == OR_ERROR_NONE) {
00079                 uint16_t compression = 0;
00080                 m_cfaIfd->getValue(IFD::EXIF_TAG_COMPRESSION, compression);
00081                 switch(compression) {
00082                 case 1:
00083                     data.setDataType(OR_DATA_TYPE_CFA);
00084                     break;
00085                 case 65535:
00086                     // TODO decompress
00087                     break;
00088                 default:
00089                     break;
00090                 }
00091             }
00092             return err;
00093         }
00094     }
00095 }
00096 

Generated on Sun Mar 23 09:28:21 2008 for libopenraw by  doxygen 1.5.5