rawfile.cpp

00001 /*
00002  * libopenraw - rawfile.cpp
00003  *
00004  * Copyright (C) 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 /* @brief C api for rawfile
00021  */
00022 
00023 #include <boost/checked_delete.hpp>
00024 #include <libopenraw/libopenraw.h>
00025 
00026 
00027 #include <libopenraw++/rawfile.h>
00028 
00029 using OpenRaw::RawFile;
00030 using OpenRaw::RawData;
00031 using OpenRaw::Thumbnail;
00032 
00033 extern "C" {
00034 
00036 #define CHECK_PTR(p,r) \
00037     if(p == NULL) { return r; }
00038 
00039 ORRawFileRef
00040 or_rawfile_new(const char* filename, or_rawfile_type type)
00041 {
00042     CHECK_PTR(filename, NULL);
00043     RawFile * rawfile = RawFile::newRawFile(filename, type);
00044     return reinterpret_cast<ORRawFileRef>(rawfile);
00045 }
00046     
00047 or_error
00048 or_rawfile_release(ORRawFileRef rawfile)
00049 {
00050     CHECK_PTR(rawfile, OR_ERROR_NOTAREF);
00051     boost::checked_delete(reinterpret_cast<RawFile *>(rawfile));
00052     return OR_ERROR_NONE;
00053 }
00054 
00055 or_rawfile_type
00056 or_rawfile_get_type(ORRawFileRef rawfile)
00057 {
00058     CHECK_PTR(rawfile, OR_RAWFILE_TYPE_UNKNOWN);
00059     RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00060     return prawfile->type();
00061 }
00062 
00063 or_error
00064 or_rawfile_get_thumbnail(ORRawFileRef rawfile, uint32_t _preferred_size,
00065                          ORThumbnailRef thumb)
00066 {
00067     CHECK_PTR(rawfile, OR_ERROR_NOTAREF);
00068     RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00069     return prawfile->getThumbnail(_preferred_size, 
00070                                   *reinterpret_cast<Thumbnail*>(thumb));
00071 }
00072 
00073 or_error
00074 or_rawfile_get_rawdata(ORRawFileRef rawfile, ORRawDataRef rawdata, 
00075                        uint32_t options)
00076 {
00077     RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00078     CHECK_PTR(rawfile, OR_ERROR_NOTAREF);
00079     return prawfile->getRawData(*reinterpret_cast<RawData*>(rawdata), options);
00080 }
00081 
00082 int32_t
00083 or_rawfile_get_orientation(ORRawFileRef rawfile)
00084 {
00085     RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00086     CHECK_PTR(rawfile, 0);
00087     return prawfile->getOrientation();
00088 }
00089 
00090 }

Generated on Tue Jun 17 11:47:19 2008 for libopenraw by  doxygen 1.5.6