neffile.cpp

00001 /*
00002  * libopenraw - neffile.cpp
00003  *
00004  * Copyright (C) 2006-2007 Hubert Figuiere
00005  * Copyright (C) 2008 Novell, Inc.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00020  */
00021 
00022 
00023 #include <iostream>
00024 #include <libopenraw++/thumbnail.h>
00025 #include <libopenraw++/rawdata.h>
00026 
00027 #include "debug.h"
00028 #include "ifd.h"
00029 #include "ifdfilecontainer.h"
00030 #include "ifddir.h"
00031 #include "ifdentry.h"
00032 #include "io/file.h"
00033 #include "neffile.h"
00034 
00035 using namespace Debug;
00036 
00037 namespace OpenRaw {
00038 
00039 
00040     namespace Internals {
00041 
00042         RawFile *NEFFile::factory(const char* _filename)
00043         {
00044             return new NEFFile(_filename);
00045         }
00046 
00047         NEFFile::NEFFile(const char* _filename)
00048             : TiffEpFile(_filename, OR_RAWFILE_TYPE_NEF)
00049         {
00050         }
00051 
00052 
00053         NEFFile::~NEFFile()
00054         {
00055         }
00056 
00057         bool NEFFile::isCompressed(RawContainer & container, uint32_t offset)
00058         {
00059             int i;
00060             uint8_t buf[256];
00061             size_t real_size = container.fetchData(buf, offset, 
00062                                                    256);
00063             if(real_size != 256) {
00064                 return true;
00065             }
00066             for(i = 15; i < 256; i+= 16) {
00067                 if(buf[i]) {
00068                     Trace(DEBUG1) << "isCompressed: true\n";
00069                     return true;
00070                 }
00071             }
00072             Trace(DEBUG1) << "isCompressed: false\n";
00073             return false;
00074         }
00075 
00076         ::or_error NEFFile::_getRawData(RawData & data, uint32_t /*options*/)
00077         {
00078             ::or_error ret = OR_ERROR_NONE;
00079             m_cfaIfd = _locateCfaIfd();
00080             Trace(DEBUG1) << "_getRawData()\n";
00081 
00082             if(m_cfaIfd) {
00083                 ret = _getRawDataFromDir(data, m_cfaIfd);
00084             }
00085             else {
00086                 ret = OR_ERROR_NOT_FOUND;
00087             }
00088             return ret;
00089         }
00090 
00091     }
00092 }
00093 

Generated on Sat Nov 7 19:23:18 2009 for libopenraw by  doxygen 1.5.8