rawfile.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 }