本文整理汇总了C++中dt_image_full_path函数的典型用法代码示例。如果您正苦于以下问题:C++ dt_image_full_path函数的具体用法?C++ dt_image_full_path怎么用?C++ dt_image_full_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dt_image_full_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dt_fswatch_add
void dt_fswatch_add(const dt_fswatch_t * fswatch,dt_fswatch_type_t type, void *data)
{
char filename[DT_MAX_PATH_LEN];
uint32_t mask=0;
dt_fswatch_t *ctx=(dt_fswatch_t *)fswatch;
filename[0] = '\0';
switch(type)
{
case DT_FSWATCH_IMAGE:
mask=IN_ALL_EVENTS;
dt_image_full_path(((dt_image_t *)data)->id, filename, DT_MAX_PATH_LEN);
break;
case DT_FSWATCH_CURVE_DIRECTORY:
break;
default:
dt_print(DT_DEBUG_FSWATCH,"[fswatch_add] Unhandled object type %d\n",type);
break;
}
if(filename[0] != '\0')
{
dt_pthread_mutex_lock(&ctx->mutex);
_watch_t *item = g_malloc(sizeof(_watch_t));
item->type=type;
item->data=data;
ctx->items=g_list_append(fswatch->items, item);
item->descriptor=inotify_add_watch(fswatch->inotify_fd,filename,mask);
dt_pthread_mutex_unlock(&ctx->mutex);
dt_print(DT_DEBUG_FSWATCH,"[fswatch_add] Watch on object %p added on file %s\n", data,filename);
}
else
dt_print(DT_DEBUG_FSWATCH,"[fswatch_add] No watch added, failed to get related filename of object type %d\n",type);
}
示例2: dt_image_full_path
char *dt_get_lightroom_xmp(int imgid)
{
char pathname[DT_MAX_FILENAME_LEN];
struct stat buf;
gboolean from_cache = TRUE;
// Get full pathname
dt_image_full_path(imgid, pathname, DT_MAX_FILENAME_LEN, &from_cache);
// Look for extension
char *pos = strrchr(pathname, '.');
if(pos == NULL)
{
return NULL;
}
// If found, replace extension with xmp
strncpy(pos + 1, "xmp", 4);
if(!stat(pathname, &buf))
return g_strdup(pathname);
else
return NULL;
}
示例3: _view_map_dnd_get_callback
static void
_view_map_dnd_get_callback(GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data,
guint target_type, guint time, dt_view_t *self)
{
dt_map_t *lib = (dt_map_t*)self->data;
g_assert (selection_data != NULL);
int imgid = lib->selected_image;
switch (target_type)
{
case DND_TARGET_IMGID:
gtk_selection_data_set(selection_data, selection_data-> target, _DWORD, (guchar*) &imgid, sizeof(imgid));
break;
default: // return the location of the file as a last resort
case DND_TARGET_URI:
{
gchar pathname[DT_MAX_PATH_LEN] = {0};
dt_image_full_path(imgid, pathname, DT_MAX_PATH_LEN);
gchar *uri = g_strdup_printf("file://%s", pathname); // TODO: should we add the host?
gtk_selection_data_set(selection_data, selection_data-> target, _BYTE, (guchar*) uri, strlen(uri));
g_free(uri);
break;
}
}
}
示例4: store
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
dt_imageio_email_t *d = (dt_imageio_email_t *)sdata;
_email_attachment_t *attachment = (_email_attachment_t *)g_malloc(sizeof(_email_attachment_t));
attachment->imgid = imgid;
/* construct a temporary file name */
char tmpdir[PATH_MAX] = { 0 };
dt_loc_get_tmp_dir(tmpdir, sizeof(tmpdir));
char dirname[PATH_MAX] = { 0 };
gboolean from_cache = FALSE;
dt_image_full_path(imgid, dirname, sizeof(dirname), &from_cache);
gchar *filename = g_path_get_basename(dirname);
g_strlcpy(dirname, filename, sizeof(dirname));
dt_image_path_append_version(imgid, dirname, sizeof(dirname));
gchar *end = g_strrstr(dirname, ".") + 1;
if(end) *end = '\0';
g_strlcat(dirname, format->extension(fdata), sizeof(dirname));
// set exported filename
attachment->file = g_build_filename(tmpdir, dirname, (char *)NULL);
if(dt_imageio_export(imgid, attachment->file, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename,
icc_intent, self, sdata, num, total) != 0)
{
fprintf(stderr, "[imageio_storage_email] could not export to file: `%s'!\n", attachment->file);
dt_control_log(_("could not export to file `%s'!"), attachment->file);
g_free(attachment);
g_free(filename);
return 1;
}
char *trunc = attachment->file + strlen(attachment->file) - 32;
if(trunc < attachment->file) trunc = attachment->file;
dt_control_log(ngettext("%d/%d exported to `%s%s'", "%d/%d exported to `%s%s'", num),
num, total, trunc != filename ? ".." : "", trunc);
#ifdef _OPENMP // store can be called in parallel, so synch access to shared memory
#pragma omp critical
#endif
d->images = g_list_append(d->images, attachment);
g_free(filename);
return 0;
}
示例5: image_tostring
static int image_tostring(lua_State *L)
{
const dt_image_t * my_image=checkreadimage(L,-1);
char image_name[PATH_MAX];
dt_image_full_path(my_image->id,image_name,PATH_MAX);
dt_image_path_append_version(my_image->id,image_name,PATH_MAX);
lua_pushstring(L,image_name);
releasereadimage(L,my_image);
return 1;
}
示例6: store_wrapper
static int store_wrapper(struct dt_imageio_module_storage_t *self,struct dt_imageio_module_data_t *self_data, const int imgid, dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total, const gboolean high_quality)
{
/* construct a temporary file name */
char tmpdir[DT_MAX_PATH_LEN]= {0};
gboolean from_cache = FALSE;
dt_loc_get_tmp_dir (tmpdir,DT_MAX_PATH_LEN);
char dirname[DT_MAX_PATH_LEN];
dt_image_full_path(imgid, dirname, DT_MAX_PATH_LEN, &from_cache);
const gchar * filename = g_path_get_basename( dirname );
gchar * end = g_strrstr( filename,".")+1;
g_strlcpy( end, format->extension(fdata), sizeof(dirname)-(end-dirname));
gchar* complete_name = g_build_filename( tmpdir, filename, (char *)NULL );
if(dt_imageio_export(imgid, complete_name, format, fdata, high_quality) != 0)
{
fprintf(stderr, "[%s] could not export to file: `%s'!\n", self->name(self),complete_name);
g_free(complete_name);
return 1;
}
lua_storage_t *d = (lua_storage_t*) self_data;
d->imgids = g_list_prepend(d->imgids,(void*)(intptr_t)imgid);
d->file_names = g_list_prepend(d->file_names,complete_name);
lua_State *L =darktable.lua_state;
lua_getfield(L,LUA_REGISTRYINDEX,"dt_lua_storages");
lua_getfield(L,-1,self->plugin_name);
lua_getfield(L,-1,"store");
if(lua_isnil(L,-1)) {
lua_pop(L,3);
return 1;
}
luaA_push_typeid(L,self->parameter_lua_type,self_data);
luaA_push(L,dt_lua_image_t,&imgid);
luaA_push_typeid(L,format->parameter_lua_type,fdata);
lua_pushstring(L,complete_name);
lua_pushnumber(L,num);
lua_pushnumber(L,total);
lua_pushboolean(L,high_quality);
lua_pushlightuserdata(L,self_data);
lua_gettable(L,LUA_REGISTRYINDEX);
dt_lua_do_chunk(L,8,1);
int result = lua_toboolean(L,-1);
lua_pop(L,2);
return result;
}
示例7: image_tostring
static int image_tostring(lua_State *L)
{
const dt_image_t * my_image=checkreadimage(L,-1);
char image_name[PATH_MAX];
gboolean from_cache = FALSE;
dt_image_full_path(my_image->id, image_name, sizeof(image_name), &from_cache);
dt_image_path_append_version(my_image->id, image_name, sizeof(image_name));
lua_pushstring(L,image_name);
releasereadimage(L,my_image);
return 1;
}
示例8: sidecar_member
static int sidecar_member(lua_State *L)
{
const dt_image_t *my_image = checkreadimage(L, 1);
gboolean from_cache = TRUE;
char filename[PATH_MAX] = { 0 };
dt_image_full_path(my_image->id, filename, sizeof(filename), &from_cache);
dt_image_path_append_version(my_image->id, filename, sizeof(filename));
g_strlcat(filename, ".xmp", sizeof(filename));
lua_pushstring(L, filename);
releasereadimage(L, my_image);
return 1;
}
示例9: try_enter
int try_enter(dt_view_t *self)
{
dt_print_t *prt=(dt_print_t*)self->data;
// now check that there is at least one selected image
prt->image_id = -1;
int selected = dt_control_get_mouse_over_id();
if(selected < 0)
{
// try last selected
sqlite3_stmt *stmt;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select * from selected_images", -1, &stmt,
NULL);
if(sqlite3_step(stmt) == SQLITE_ROW) selected = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
// Leave as selected only the image being edited
DT_DEBUG_SQLITE3_EXEC(dt_database_get(darktable.db), "delete from selected_images", NULL, NULL, NULL);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"insert or ignore into selected_images values (?1)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, selected);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
if(selected < 0)
{
// fail :(
dt_control_log(_("no image selected!"));
return 1;
}
// this loads the image from db if needed:
const dt_image_t *img = dt_image_cache_get(darktable.image_cache, selected, 'r');
// get image and check if it has been deleted from disk first!
char imgfilename[PATH_MAX] = { 0 };
gboolean from_cache = TRUE;
dt_image_full_path(img->id, imgfilename, sizeof(imgfilename), &from_cache);
if(!g_file_test(imgfilename, G_FILE_TEST_IS_REGULAR))
{
dt_control_log(_("image `%s' is currently unavailable"), img->filename);
// dt_image_remove(selected);
dt_image_cache_read_release(darktable.image_cache, img);
return 1;
}
// and drop the lock again.
dt_image_cache_read_release(darktable.image_cache, img);
prt->image_id = selected;
return 0;
}
示例10: write_image
// FIXME: we can't rely on darktable to avoid file overwriting -- it doesn't know the filename (extension).
int write_image(dt_imageio_module_data_t *data, const char *filename, const void *in,
dt_colorspaces_color_profile_type_t over_type, const char *over_filename,
void *exif, int exif_len, int imgid, int num, int total, struct dt_dev_pixelpipe_t *pipe)
{
int status = 1;
gboolean from_cache = TRUE;
char sourcefile[PATH_MAX];
char *targetfile = NULL;
char *xmpfile = NULL;
char *content = NULL;
FILE *fin = NULL;
FILE *fout = NULL;
dt_image_full_path(imgid, sourcefile, sizeof(sourcefile), &from_cache);
char *extension = g_strrstr(sourcefile, ".");
if(extension == NULL) goto END;
targetfile = g_strconcat(filename, ++extension, NULL);
if(!strcmp(sourcefile, targetfile)) goto END;
fin = g_fopen(sourcefile, "rb");
fout = g_fopen(targetfile, "wb");
if(fin == NULL || fout == NULL) goto END;
fseek(fin, 0, SEEK_END);
size_t end = ftell(fin);
rewind(fin);
content = (char *)g_malloc_n(end, sizeof(char));
if(content == NULL) goto END;
if(fread(content, sizeof(char), end, fin) != end) goto END;
if(fwrite(content, sizeof(char), end, fout) != end) goto END;
// we got a copy of the file, now write the xmp data
xmpfile = g_strconcat(targetfile, ".xmp", NULL);
if(dt_exif_xmp_write(imgid, xmpfile) != 0)
{
// something went wrong, unlink the copied image.
g_unlink(targetfile);
goto END;
}
status = 0;
END:
g_free(targetfile);
g_free(xmpfile);
g_free(content);
if(fin) fclose(fin);
if(fout) fclose(fout);
return status;
}
示例11: dt_image_write_sidecar_file
void dt_image_write_sidecar_file(int imgid)
{
// TODO: compute hash and don't write if not needed!
// write .xmp file
if(imgid > 0 && dt_conf_get_bool("write_sidecar_files"))
{
char filename[DT_MAX_PATH_LEN+8];
dt_image_full_path(imgid, filename, DT_MAX_PATH_LEN);
dt_image_path_append_version(imgid, filename, DT_MAX_PATH_LEN);
char *c = filename + strlen(filename);
sprintf(c, ".xmp");
dt_exif_xmp_write(imgid, filename);
}
}
示例12: dt_control_write_sidecar_files_job_run
int32_t dt_control_write_sidecar_files_job_run(dt_job_t *job)
{
long int imgid = -1;
dt_control_image_enumerator_t *t1 = (dt_control_image_enumerator_t *)job->param;
GList *t = t1->index;
while(t)
{
imgid = (long int)t->data;
const dt_image_t *img = dt_image_cache_read_get(darktable.image_cache, (int32_t)imgid);
char dtfilename[DT_MAX_PATH_LEN+4];
dt_image_full_path(img->id, dtfilename, DT_MAX_PATH_LEN);
char *c = dtfilename + strlen(dtfilename);
sprintf(c, ".xmp");
dt_exif_xmp_write(imgid, dtfilename);
dt_image_cache_read_release(darktable.image_cache, img);
t = g_list_delete_link(t, t);
}
return 0;
}
示例13: store
int
store (dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid, dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata,
const int num, const int total, const gboolean high_quality)
{
dt_imageio_email_t *d = (dt_imageio_email_t *)sdata;
_email_attachment_t *attachment = ( _email_attachment_t *)g_malloc(sizeof(_email_attachment_t));
attachment->imgid = imgid;
/* construct a temporary file name */
char tmpdir[4096]= {0};
dt_loc_get_tmp_dir (tmpdir,4096);
char dirname[4096];
dt_image_full_path(imgid, dirname, 1024);
const gchar * filename = g_path_get_basename( dirname );
gchar * end = g_strrstr( filename,".")+1;
g_strlcpy( end, format->extension(fdata), sizeof(dirname)-(end-dirname));
attachment->file = g_build_filename( tmpdir, filename, (char *)NULL );
if(dt_imageio_export(imgid, attachment->file, format, fdata, high_quality) != 0)
{
fprintf(stderr, "[imageio_storage_email] could not export to file: `%s'!\n", attachment->file);
dt_control_log(_("could not export to file `%s'!"), attachment->file);
g_free(attachment);
return 1;
}
char *trunc = attachment->file + strlen(attachment->file) - 32;
if(trunc < attachment->file) trunc = attachment->file;
dt_control_log(_("%d/%d exported to `%s%s'"), num, total, trunc != filename ? ".." : "", trunc);
#ifdef _OPENMP // store can be called in parallel, so synch access to shared memory
#pragma omp critical
#endif
d->images = g_list_append( d->images, attachment );
return 0;
}
示例14: dt_control_merge_hdr_job_run
//.........这里部分代码省略.........
pixels = (float *)malloc(sizeof(float)*image.width*image.height);
weight = (float *)malloc(sizeof(float)*image.width*image.height);
memset(pixels, 0x0, sizeof(float)*image.width*image.height);
memset(weight, 0x0, sizeof(float)*image.width*image.height);
wd = image.width;
ht = image.height;
}
else if(image.width != wd || image.height != ht)
{
dt_control_log(_("images have to be of same size!"));
free(pixels);
free(weight);
dt_mipmap_cache_read_release(darktable.mipmap_cache, &buf);
goto error;
}
// if no valid exif data can be found, assume peleng fisheye at f/16, 8mm, with half of the light lost in the system => f/22
const float eap = image.exif_aperture > 0.0f ? image.exif_aperture : 22.0f;
const float efl = image.exif_focal_length > 0.0f ? image.exif_focal_length : 8.0f;
const float rad = .5f * efl/eap;
const float aperture = M_PI * rad * rad;
const float iso = image.exif_iso > 0.0f ? image.exif_iso : 100.0f;
const float exp = image.exif_exposure > 0.0f ? image.exif_exposure : 1.0f;
const float cal = 100.0f/(aperture*exp*iso);
// about proportional to how many photons we can expect from this shot:
const float photoncnt = 100.0f*aperture*exp/iso;
// stupid, but we don't know the real sensor saturation level:
uint16_t saturation = 0;
for(int k=0; k<wd*ht; k++)
saturation = MAX(saturation, ((uint16_t *)buf.buf)[k]);
// seems to be around 64500--64700 for 5dm2
// fprintf(stderr, "saturation: %u\n", saturation);
whitelevel = fmaxf(whitelevel, saturation*cal);
#ifdef _OPENMP
#pragma omp parallel for schedule(static) default(none) shared(buf, pixels, weight, wd, ht, saturation)
#endif
for(int k=0; k<wd*ht; k++)
{
const uint16_t in = ((uint16_t *)buf.buf)[k];
// weights based on siggraph 12 poster
// zijian zhu, zhengguo li, susanto rahardja, pasi fraenti
// 2d denoising factor for high dynamic range imaging
float w = envelope(in/(float)saturation) * photoncnt;
// in case we are black and drop to zero weight, give it something
// just so numerics don't collapse. blown out whites are handled below.
if(w < 1e-3f && in < saturation/3) w = 1e-3f;
pixels[k] += w * in * cal;
weight[k] += w;
}
t = g_list_delete_link(t, t);
/* update backgroundjob ui plate */
fraction+=1.0/total;
dt_control_backgroundjobs_progress(darktable.control, jid, fraction);
dt_mipmap_cache_read_release(darktable.mipmap_cache, &buf);
}
// normalize by white level to make clipping at 1.0 work as expected (to be sure, scale down one more stop, thus the 0.5):
#ifdef _OPENMP
#pragma omp parallel for schedule(static) default(none) shared(pixels, wd, ht, weight, whitelevel)
#endif
for(int k=0; k<wd*ht; k++)
{
// in case w == 0, all pixels were overexposed (too dark would have been clamped to w >= eps above)
if(weight[k] < 1e-3f)
pixels[k] = 1.f; // mark as blown out.
else // normalize:
pixels[k] = fmaxf(0.0f, pixels[k]/(whitelevel*weight[k]));
}
// output hdr as digital negative with exif data.
uint8_t exif[65535];
char pathname[DT_MAX_PATH_LEN];
dt_image_full_path(first_imgid, pathname, DT_MAX_PATH_LEN);
// last param is dng mode
const int exif_len = dt_exif_read_blob(exif, pathname, first_imgid, 0, wd, ht, 1);
char *c = pathname + strlen(pathname);
while(*c != '.' && c > pathname) c--;
g_strlcpy(c, "-hdr.dng", sizeof(pathname)-(c-pathname));
dt_imageio_write_dng(pathname, pixels, wd, ht, exif, exif_len, filter, 1.0f);
dt_control_backgroundjobs_progress(darktable.control, jid, 1.0f);
while(*c != '/' && c > pathname) c--;
dt_control_log(_("wrote merged hdr `%s'"), c+1);
// import new image
gchar *directory = g_path_get_dirname((const gchar *)pathname);
dt_film_t film;
const int filmid = dt_film_new(&film, directory);
dt_image_import(filmid, pathname, TRUE);
g_free (directory);
free(pixels);
free(weight);
error:
dt_control_backgroundjobs_destroy(darktable.control, jid);
dt_control_queue_redraw_center();
return 0;
}
示例15: dt_image_move
int32_t dt_image_move(const int32_t imgid, const int32_t filmid)
{
//TODO: several places where string truncation could occur unnoticed
int32_t result = -1;
gchar oldimg[DT_MAX_PATH_LEN] = {0};
gchar newimg[DT_MAX_PATH_LEN] = {0};
dt_image_full_path(imgid, oldimg, DT_MAX_PATH_LEN);
gchar *newdir = NULL;
sqlite3_stmt *film_stmt;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"select folder from film_rolls where id = ?1", -1, &film_stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(film_stmt, 1, filmid);
if(sqlite3_step(film_stmt) == SQLITE_ROW)
newdir = g_strdup((gchar *) sqlite3_column_text(film_stmt, 0));
sqlite3_finalize(film_stmt);
if(newdir)
{
gchar *imgbname = g_path_get_basename(oldimg);
g_snprintf(newimg, DT_MAX_PATH_LEN, "%s%c%s", newdir, G_DIR_SEPARATOR, imgbname);
g_free(imgbname);
g_free(newdir);
// statement for getting ids of the image to be moved and it's duplicates
sqlite3_stmt *duplicates_stmt;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"select id from images where filename in (select filename from images "
"where id = ?1) and film_id in (select film_id from images where id = ?1)",
-1, &duplicates_stmt, NULL);
// move image
// TODO: Use gio's' g_file_move instead of g_rename?
if (!g_file_test(newimg, G_FILE_TEST_EXISTS)
&& (g_rename(oldimg, newimg) == 0))
{
// first move xmp files of image and duplicates
GList *dup_list = NULL;
DT_DEBUG_SQLITE3_BIND_INT(duplicates_stmt, 1, imgid);
while (sqlite3_step(duplicates_stmt) == SQLITE_ROW)
{
int32_t id = sqlite3_column_int(duplicates_stmt, 0);
dup_list = g_list_append(dup_list, GINT_TO_POINTER(id));
gchar oldxmp[512], newxmp[512];
g_strlcpy(oldxmp, oldimg, 512);
g_strlcpy(newxmp, newimg, 512);
dt_image_path_append_version(id, oldxmp, 512);
dt_image_path_append_version(id, newxmp, 512);
g_strlcat(oldxmp, ".xmp", 512);
g_strlcat(newxmp, ".xmp", 512);
if (g_file_test(oldxmp, G_FILE_TEST_EXISTS))
(void)g_rename(oldxmp, newxmp);
}
sqlite3_reset(duplicates_stmt);
sqlite3_clear_bindings(duplicates_stmt);
// then update database and cache
// if update was performed in above loop, dt_image_path_append_version()
// would return wrong version!
while (dup_list)
{
long int id = GPOINTER_TO_INT(dup_list->data);
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, id);
dt_image_t *img = dt_image_cache_write_get(darktable.image_cache, cimg);
img->film_id = filmid;
// write through to db, but not to xmp
dt_image_cache_write_release(darktable.image_cache, img, DT_IMAGE_CACHE_RELAXED);
dt_image_cache_read_release(darktable.image_cache, img);
dup_list = g_list_delete_link(dup_list, dup_list);
}
g_list_free(dup_list);
result = 0;
}
}
return result;
}