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 #include <libopenraw++/bitmapdata.h>
00029
00030 using OpenRaw::RawFile;
00031 using OpenRaw::RawData;
00032 using OpenRaw::BitmapData;
00033 using OpenRaw::Thumbnail;
00034
00035 extern "C" {
00036
00038 #define CHECK_PTR(p,r) \
00039 if(p == NULL) { return r; }
00040
00041 const char **or_get_file_extensions()
00042 {
00043 return RawFile::fileExtensions();
00044 }
00045
00046 ORRawFileRef
00047 or_rawfile_new(const char* filename, or_rawfile_type type)
00048 {
00049 CHECK_PTR(filename, NULL);
00050 RawFile * rawfile = RawFile::newRawFile(filename, type);
00051 return reinterpret_cast<ORRawFileRef>(rawfile);
00052 }
00053
00054 ORRawFileRef
00055 or_rawfile_new_from_memory(const uint8_t *buffer, uint32_t len, or_rawfile_type type)
00056 {
00057 CHECK_PTR(buffer, NULL);
00058 RawFile * rawfile = RawFile::newRawFileFromMemory(buffer, len, type);
00059 return reinterpret_cast<ORRawFileRef>(rawfile);
00060 }
00061
00062
00063 or_error
00064 or_rawfile_release(ORRawFileRef rawfile)
00065 {
00066 CHECK_PTR(rawfile, OR_ERROR_NOTAREF);
00067 boost::checked_delete(reinterpret_cast<RawFile *>(rawfile));
00068 return OR_ERROR_NONE;
00069 }
00070
00071 or_rawfile_type
00072 or_rawfile_get_type(ORRawFileRef rawfile)
00073 {
00074 CHECK_PTR(rawfile, OR_RAWFILE_TYPE_UNKNOWN);
00075 RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00076 return prawfile->type();
00077 }
00078
00079 or_error
00080 or_rawfile_get_thumbnail(ORRawFileRef rawfile, uint32_t _preferred_size,
00081 ORThumbnailRef thumb)
00082 {
00083 CHECK_PTR(rawfile, OR_ERROR_NOTAREF);
00084 RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00085 return prawfile->getThumbnail(_preferred_size,
00086 *reinterpret_cast<Thumbnail*>(thumb));
00087 }
00088
00089 or_error
00090 or_rawfile_get_rawdata(ORRawFileRef rawfile, ORRawDataRef rawdata,
00091 uint32_t options)
00092 {
00093 RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00094 CHECK_PTR(rawfile, OR_ERROR_NOTAREF);
00095 return prawfile->getRawData(*reinterpret_cast<RawData*>(rawdata), options);
00096 }
00097
00098 or_error
00099 or_rawfile_get_rendered_image(ORRawFileRef rawfile, ORBitmapDataRef bitmapdata,
00100 uint32_t options)
00101 {
00102 RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00103 CHECK_PTR(rawfile, OR_ERROR_NOTAREF);
00104 return prawfile->getRenderedImage(*reinterpret_cast<BitmapData*>(bitmapdata), options);
00105 }
00106
00107 int32_t
00108 or_rawfile_get_orientation(ORRawFileRef rawfile)
00109 {
00110 RawFile * prawfile = reinterpret_cast<RawFile *>(rawfile);
00111 CHECK_PTR(rawfile, 0);
00112 return prawfile->getOrientation();
00113 }
00114
00115 }