libopenraw
|
00001 /* 00002 * libopenraw - peffile.cpp 00003 * 00004 * Copyright (C) 2006-2008 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 License 00008 * as published by the Free Software Foundation, either version 3 of 00009 * 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, see 00018 * <http://www.gnu.org/licenses/>. 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 const struct IFDFile::camera_ids_t PEFFile::s_def[] = { 00041 { "PENTAX *ist D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 00042 OR_TYPEID_PENTAX_IST_D) }, 00043 { "PENTAX *ist DL ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 00044 OR_TYPEID_PENTAX_IST_DL) }, 00045 { "PENTAX K10D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 00046 OR_TYPEID_PENTAX_K10D_PEF) }, 00047 { "PENTAX K100D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 00048 OR_TYPEID_PENTAX_K100D_PEF) }, 00049 { "PENTAX K100D Super ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX, 00050 OR_TYPEID_PENTAX_K100D_PEF) }, 00051 { 0, 0 } 00052 }; 00053 00054 00055 RawFile *PEFFile::factory(IO::Stream *s) 00056 { 00057 return new PEFFile(s); 00058 } 00059 00060 PEFFile::PEFFile(IO::Stream *s) 00061 : IFDFile(s, OR_RAWFILE_TYPE_PEF) 00062 { 00063 _setIdMap(s_def); 00064 } 00065 00066 00067 PEFFile::~PEFFile() 00068 { 00069 } 00070 00071 IFDDir::Ref PEFFile::_locateCfaIfd() 00072 { 00073 // in PEF the CFA IFD is the main IFD 00074 if(!m_mainIfd) { 00075 m_mainIfd = _locateMainIfd(); 00076 } 00077 return m_mainIfd; 00078 } 00079 00080 00081 IFDDir::Ref PEFFile::_locateMainIfd() 00082 { 00083 return m_container->setDirectory(0); 00084 } 00085 00086 ::or_error PEFFile::_getRawData(RawData & data, uint32_t /*options*/) 00087 { 00088 ::or_error err; 00089 if(!m_cfaIfd) { 00090 m_cfaIfd = _locateCfaIfd(); 00091 } 00092 err = _getRawDataFromDir(data, m_cfaIfd); 00093 if(err == OR_ERROR_NONE) { 00094 uint16_t compression = 0; 00095 m_cfaIfd->getValue(IFD::EXIF_TAG_COMPRESSION, compression); 00096 switch(compression) { 00097 case 1: 00098 data.setDataType(OR_DATA_TYPE_CFA); 00099 break; 00100 case 65535: 00101 // TODO decompress 00102 break; 00103 default: 00104 break; 00105 } 00106 } 00107 return err; 00108 } 00109 } 00110 } 00111