@@ -445,6 +445,19 @@ if(UNIX)
|
||||
install(FILES rawtherapee.appdata.xml DESTINATION "${APPDATADIR}")
|
||||
endif()
|
||||
|
||||
# check whether the used version of lensfun has lfDatabase::LoadDirectory
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${LENSFUN_INCLUDE_DIRS})
|
||||
check_cxx_source_compiles(
|
||||
"#include <lensfun.h>
|
||||
int main()
|
||||
{
|
||||
lfDatabase *db = 0;
|
||||
bool b = db->LoadDirectory(0);
|
||||
return 0;
|
||||
}" LENSFUN_HAS_LOAD_DIRECTORY)
|
||||
|
||||
|
||||
add_subdirectory(rtexif)
|
||||
add_subdirectory(rtengine)
|
||||
add_subdirectory(rtgui)
|
||||
|
@@ -113,6 +113,11 @@ set(RTENGINESOURCEFILES
|
||||
rtlensfun.cc
|
||||
)
|
||||
|
||||
if(LENSFUN_HAS_LOAD_DIRECTORY)
|
||||
set_source_files_properties(rtlensfun.cc PROPERTIES COMPILE_DEFINITIONS RT_LENSFUN_HAS_LOAD_DIRECTORY)
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT WITH_SYSTEM_KLT)
|
||||
set(RTENGINESOURCEFILES ${RTENGINESOURCEFILES}
|
||||
klt/convolve.cc
|
||||
|
@@ -267,7 +267,12 @@ bool LFDatabase::init(const Glib::ustring &dbdir)
|
||||
std::cout << "..." << std::flush;
|
||||
}
|
||||
|
||||
bool ok = dbdir.empty() ? (instance_.data_->Load() == LF_NO_ERROR) : instance_.data_->LoadDirectory(dbdir.c_str());
|
||||
bool ok = false;
|
||||
if (dbdir.empty()) {
|
||||
ok = (instance_.data_->Load() == LF_NO_ERROR);
|
||||
} else {
|
||||
ok = instance_.LoadDirectory(dbdir.c_str());
|
||||
}
|
||||
|
||||
if (settings->verbose) {
|
||||
std::cout << (ok ? "OK" : "FAIL") << std::endl;
|
||||
@@ -277,6 +282,43 @@ bool LFDatabase::init(const Glib::ustring &dbdir)
|
||||
}
|
||||
|
||||
|
||||
bool LFDatabase::LoadDirectory(const char *dirname)
|
||||
{
|
||||
#if RT_LENSFUN_HAS_LOAD_DIRECTORY
|
||||
instance_.data_->LoadDirectory(dirname);
|
||||
#else
|
||||
// backported from lensfun 0.3.x
|
||||
bool database_found = false;
|
||||
|
||||
GDir *dir = g_dir_open (dirname, 0, NULL);
|
||||
if (dir)
|
||||
{
|
||||
GPatternSpec *ps = g_pattern_spec_new ("*.xml");
|
||||
if (ps)
|
||||
{
|
||||
const gchar *fn;
|
||||
while ((fn = g_dir_read_name (dir)))
|
||||
{
|
||||
size_t sl = strlen (fn);
|
||||
if (g_pattern_match (ps, sl, fn, NULL))
|
||||
{
|
||||
gchar *ffn = g_build_filename (dirname, fn, NULL);
|
||||
/* Ignore errors */
|
||||
if (data_->Load (ffn) == LF_NO_ERROR)
|
||||
database_found = true;
|
||||
g_free (ffn);
|
||||
}
|
||||
}
|
||||
g_pattern_spec_free (ps);
|
||||
}
|
||||
g_dir_close (dir);
|
||||
}
|
||||
|
||||
return database_found;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
LFDatabase::LFDatabase():
|
||||
data_(nullptr)
|
||||
{
|
||||
|
@@ -117,6 +117,8 @@ private:
|
||||
float focalLen, float aperture, float focusDist,
|
||||
int width, int height, bool swap_xy) const;
|
||||
LFDatabase();
|
||||
bool LoadDirectory(const char *dirname);
|
||||
|
||||
static LFDatabase instance_;
|
||||
lfDatabase *data_;
|
||||
};
|
||||
|
Reference in New Issue
Block a user