本文整理汇总了C++中dt_image_cache_read_release函数的典型用法代码示例。如果您正苦于以下问题:C++ dt_image_cache_read_release函数的具体用法?C++ dt_image_cache_read_release怎么用?C++ dt_image_cache_read_release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dt_image_cache_read_release函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dt_dev_reload_image
void dt_dev_reload_image(dt_develop_t *dev, const uint32_t imgid)
{
const dt_image_t *image = dt_image_cache_read_get(darktable.image_cache, imgid);
dev->image_storage = *image;
dt_image_cache_read_release(darktable.image_cache, image);
dev->image_force_reload = dev->image_loading = dev->preview_loading = 1;
dev->pipe->changed |= DT_DEV_PIPE_SYNCH;
dt_dev_invalidate(dev); // only invalidate image, preview will follow once it's loaded.
}
示例2: dt_image_remove
void dt_image_remove(const int32_t imgid)
{
sqlite3_stmt *stmt;
const dt_image_t *img = dt_image_cache_read_get(darktable.image_cache, imgid);
int old_group_id = img->group_id;
dt_image_cache_read_release(darktable.image_cache, img);
// make sure we remove from the cache first, or else the cache will look for imgid in sql
dt_image_cache_remove(darktable.image_cache, imgid);
int new_group_id = dt_grouping_remove_from_group(imgid);
if(darktable.gui && darktable.gui->expanded_group_id == old_group_id)
darktable.gui->expanded_group_id = new_group_id;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from images where id = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"update tagxtag set count = count - 1 where "
"(id2 in (select tagid from tagged_images where imgid = ?1)) or "
"(id1 in (select tagid from tagged_images where imgid = ?1))",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from tagged_images where imgid = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from history where imgid = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from color_labels where imgid = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from meta_data where id = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from selected_images where imgid = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
// also clear all thumbnails in mipmap_cache.
dt_mipmap_cache_remove(darktable.mipmap_cache, imgid);
}
示例3: dt_ratings_apply_to_image
void dt_ratings_apply_to_image (int imgid, int rating)
{
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, imgid);
dt_image_t *image = dt_image_cache_write_get(darktable.image_cache, cimg);
// one star is a toggle, so you can easily reject images by removing the last star:
if(((image->flags & 0x7) == 1) && (rating == 1)) rating = 0;
image->flags = (image->flags & ~0x7) | (0x7 & rating);
// synch through:
dt_image_cache_write_release(darktable.image_cache, image, DT_IMAGE_CACHE_SAFE);
dt_image_cache_read_release(darktable.image_cache, image);
dt_collection_hint_message(darktable.collection);
}
示例4: remove_preset_flag
static void
remove_preset_flag(const int imgid)
{
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, imgid);
dt_image_t *image = dt_image_cache_write_get(darktable.image_cache, cimg);
// clear flag
image->flags &= ~DT_IMAGE_AUTO_PRESETS_APPLIED;
// write through to sql+xmp
dt_image_cache_write_release(darktable.image_cache, image, DT_IMAGE_CACHE_SAFE);
dt_image_cache_read_release(darktable.image_cache, cimg);
}
示例5: _lib_filmstrip_button_press_callback
static gboolean _lib_filmstrip_button_press_callback(GtkWidget *w, GdkEventButton *e, gpointer user_data)
{
dt_lib_module_t *self = (dt_lib_module_t *)user_data;
dt_lib_filmstrip_t *strip = (dt_lib_filmstrip_t *)self->data;
int32_t mouse_over_id = strip->mouse_over_id;
/* is this an activation of image */
if (e->button == 1 && e->type == GDK_2BUTTON_PRESS)
if (mouse_over_id > 0)
{
strip->activated_image = mouse_over_id;
dt_control_signal_raise(darktable.signals, DT_SIGNAL_VIEWMANAGER_FILMSTRIP_ACTIVATE);
return TRUE;
}
/* let check if any thumb controls was clicked */
switch(strip->image_over)
{
case DT_VIEW_DESERT:
break;
case DT_VIEW_REJECT:
case DT_VIEW_STAR_1:
case DT_VIEW_STAR_2:
case DT_VIEW_STAR_3:
case DT_VIEW_STAR_4:
case DT_VIEW_STAR_5:
{
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, mouse_over_id);
dt_image_t *image = dt_image_cache_write_get(darktable.image_cache, cimg);
image->dirty = 1;
if(strip->image_over == DT_VIEW_STAR_1 && ((image->flags & 0x7) == 1)) image->flags &= ~0x7;
else if(strip->image_over == DT_VIEW_REJECT && ((image->flags & 0x7) == 6)) image->flags &= ~0x7;
else
{
image->flags &= ~0x7;
image->flags |= strip->image_over;
}
dt_image_cache_write_release(darktable.image_cache, image, DT_IMAGE_CACHE_SAFE);
dt_image_cache_read_release(darktable.image_cache, image);
break;
}
default:
return FALSE;
}
return TRUE;
}
示例6: finalize_store
void
finalize_store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *params)
{
dt_imageio_email_t *d = (dt_imageio_email_t *)params;
// All images are exported, generate a mailto uri and startup default mail client
gchar uri[4096]= {0};
gchar body[4096]= {0};
gchar attachments[4096]= {0};
gchar *uriFormat=NULL;
gchar *subject=_("images exported from darktable");
gchar *imageBodyFormat="%s %s"; // filename, exif oneliner
gchar *attachmentFormat=NULL;
gchar *attachmentSeparator="";
// If no default handler detected above, we use gtk_show_uri with mailto:// and hopes things goes right..
uriFormat="xdg-email --subject \"%s\" --body \"%s\" %s &"; // subject, body, and list of attachments with format:
attachmentFormat=" --attach \"%s\"";
while( d->images )
{
gchar exif[256]= {0};
_email_attachment_t *attachment=( _email_attachment_t *)d->images->data;
gchar *filename = g_path_get_basename( attachment->file );
const dt_image_t *img = dt_image_cache_read_get(darktable.image_cache, attachment->imgid);
dt_image_print_exif(img, exif, sizeof(exif));
g_snprintf(body+strlen(body),4096-strlen(body), imageBodyFormat, filename, exif );
g_free(filename);
if( strlen( attachments ) )
g_snprintf(attachments+strlen(attachments),4096-strlen(attachments), "%s", attachmentSeparator );
g_snprintf(attachments+strlen(attachments),4096-strlen(attachments), attachmentFormat, attachment->file );
// Free attachment item and remove
dt_image_cache_read_release(darktable.image_cache, img);
g_free( d->images->data );
d->images = g_list_remove( d->images, d->images->data );
}
// build uri and launch before we quit...
g_snprintf(uri, sizeof(uri), uriFormat, subject, body, attachments );
fprintf(stderr, "[email] launching `%s'\n", uri);
if(system( uri ) < 0)
{
// TODO: after string freeze is broken again, report to ui:
// dt_control_log(_("could not launch email client!"));
fprintf(stderr, "[email] could not launch subprocess!\n");
}
}
示例7: dt_image_set_location
void dt_image_set_location(const int32_t imgid, double lon, double lat)
{
/* fetch image from cache */
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, imgid);
if (!cimg)
return;
dt_image_t *image = dt_image_cache_write_get(darktable.image_cache, cimg);
/* set image location */
image->longitude = lon;
image->latitude = lat;
/* store */
dt_image_cache_write_release(darktable.image_cache, image, DT_IMAGE_CACHE_SAFE);
dt_image_cache_read_release(darktable.image_cache, image);
}
示例8: group_with
int group_with(lua_State *L) {
dt_lua_image_t first_image;
luaA_to(L,dt_lua_image_t,&first_image,1);
if(lua_isnoneornil(L,2)) {
dt_grouping_remove_from_group(first_image);
return 0;
}
dt_lua_image_t second_image;
luaA_to(L,dt_lua_image_t,&second_image,2);
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, second_image);
int group_id = cimg->group_id;
dt_image_cache_read_release(darktable.image_cache, cimg);
dt_grouping_add_to_group(group_id,first_image);
return 0;
}
示例9: deflicker_prepare_histogram
static void deflicker_prepare_histogram(dt_iop_module_t *self, uint32_t **histogram,
dt_dev_histogram_stats_t *histogram_stats)
{
dt_mipmap_buffer_t buf;
dt_mipmap_cache_get(darktable.mipmap_cache, &buf, self->dev->image_storage.id, DT_MIPMAP_FULL,
DT_MIPMAP_BLOCKING, 'r');
const dt_image_t *img = dt_image_cache_get(darktable.image_cache, self->dev->image_storage.id, 'r');
dt_image_t image = *img;
dt_image_cache_read_release(darktable.image_cache, img);
if(!buf.buf)
{
dt_control_log(_("failed to get raw buffer from image `%s'"), image.filename);
dt_mipmap_cache_release(darktable.mipmap_cache, &buf);
return;
}
dt_dev_histogram_collection_params_t histogram_params = { 0 };
dt_histogram_roi_t histogram_roi = {.width = image.width,
.height = image.height,
// FIXME: get those from rawprepare IOP somehow !!!
.crop_x = image.crop_x,
.crop_y = image.crop_y,
.crop_width = image.crop_width,
.crop_height = image.crop_height };
histogram_params.roi = &histogram_roi;
histogram_params.bins_count = 16384;
dt_histogram_worker(&histogram_params, histogram_stats, buf.buf, histogram,
dt_histogram_helper_cs_RAW_uint16);
histogram_stats->ch = 1u;
dt_mipmap_cache_release(darktable.mipmap_cache, &buf);
}
/* input: 0 - 16384 (valid range: from black level to white level) */
/* output: -14 ... 0 */
static float raw_to_ev(uint32_t raw, uint32_t black_level, uint32_t white_level)
{
uint32_t raw_max = white_level - black_level;
float raw_ev = -log2f(raw_max) + log2f(CLAMP(raw, 0.0f, 16384.0f));
return raw_ev;
}
示例10: finalize_store
void finalize_store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *params)
{
dt_imageio_email_t *d = (dt_imageio_email_t *)params;
// All images are exported, generate a mailto uri and startup default mail client
gchar uri[4096] = { 0 };
gchar body[4096] = { 0 };
gchar attachments[4096] = { 0 };
gchar *uriFormat = "xdg-email --subject \"%s\" --body \"%s\" %s &"; // subject, body format
const gchar *subject = _("images exported from darktable");
const gchar *imageBodyFormat = " - %s (%s)\\n"; // filename, exif oneliner
gchar *attachmentFormat = " --attach \"%s\""; // list of attachments format
gchar *attachmentSeparator = "";
while(d->images)
{
gchar exif[256] = { 0 };
_email_attachment_t *attachment = (_email_attachment_t *)d->images->data;
gchar *filename = g_path_get_basename(attachment->file);
const dt_image_t *img = dt_image_cache_get(darktable.image_cache, attachment->imgid, 'r');
dt_image_print_exif(img, exif, sizeof(exif));
g_snprintf(body + strlen(body), sizeof(body) - strlen(body), imageBodyFormat, filename, exif);
g_free(filename);
if(*attachments)
g_snprintf(attachments + strlen(attachments), sizeof(attachments) - strlen(attachments), "%s",
attachmentSeparator);
g_snprintf(attachments + strlen(attachments), sizeof(attachments) - strlen(attachments), attachmentFormat,
attachment->file);
// Free attachment item and remove
dt_image_cache_read_release(darktable.image_cache, img);
g_free(d->images->data);
d->images = g_list_remove(d->images, d->images->data);
}
// build uri and launch before we quit...
g_snprintf(uri, sizeof(uri), uriFormat, subject, body, attachments);
fprintf(stderr, "[email] launching `%s'\n", uri);
if(system(uri) < 0)
{
dt_control_log(_("could not launch email client!"));
}
}
示例11: dt_grouping_remove_from_group
/** remove an image from a group */
int dt_grouping_remove_from_group(int image_id)
{
sqlite3_stmt *stmt;
int new_group_id = -1;
const dt_image_t *img = dt_image_cache_get(darktable.image_cache, image_id, 'r');
int img_group_id = img->group_id;
dt_image_cache_read_release(darktable.image_cache, img);
if(img_group_id == image_id)
{
// get a new group_id for all the others in the group. also write it to the dt_image_t struct.
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"select id from images where group_id = ?1 and id != ?2", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, img_group_id);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, image_id);
while(sqlite3_step(stmt) == SQLITE_ROW)
{
int other_id = sqlite3_column_int(stmt, 0);
if(new_group_id == -1) new_group_id = other_id;
dt_image_t *other_img = dt_image_cache_get(darktable.image_cache, other_id, 'w');
other_img->group_id = new_group_id;
dt_image_cache_write_release(darktable.image_cache, other_img, DT_IMAGE_CACHE_SAFE);
}
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"update images set group_id = ?1 where group_id = ?2 and id != ?3", -1, &stmt,
NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, new_group_id);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, img_group_id);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, image_id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
else
{
// change the group_id for this image.
dt_image_t *wimg = dt_image_cache_get(darktable.image_cache, image_id, 'w');
new_group_id = wimg->group_id;
wimg->group_id = image_id;
dt_image_cache_write_release(darktable.image_cache, wimg, DT_IMAGE_CACHE_SAFE);
}
return new_group_id;
}
示例12: _lib_filmstrip_ratings_key_accel_callback
static gboolean _lib_filmstrip_ratings_key_accel_callback(GtkAccelGroup *accel_group,
GObject *aceeleratable, guint keyval,
GdkModifierType modifier, gpointer data)
{
long int num = (long int)data;
switch (num)
{
case DT_VIEW_DESERT:
case DT_VIEW_REJECT:
case DT_VIEW_STAR_1:
case DT_VIEW_STAR_2:
case DT_VIEW_STAR_3:
case DT_VIEW_STAR_4:
case DT_VIEW_STAR_5:
case 666:
{
int32_t mouse_over_id;
DT_CTL_GET_GLOBAL(mouse_over_id, lib_image_mouse_over_id);
if (mouse_over_id <= 0) return FALSE;
/* get image from cache */
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, mouse_over_id);
dt_image_t *image = dt_image_cache_write_get(darktable.image_cache, cimg);
if (num == 666)
image->flags &= ~0xf;
else if (num == DT_VIEW_STAR_1 && ((image->flags & 0x7) == 1))
image->flags &= ~0x7;
else
{
image->flags &= ~0x7;
image->flags |= num;
}
dt_image_cache_write_release(darktable.image_cache, image, DT_IMAGE_CACHE_SAFE);
dt_image_cache_read_release(darktable.image_cache, image);
/* redraw all */
dt_control_queue_redraw();
break;
}
default:
break;
}
return TRUE;
}
示例13: 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;
}
示例14: _view_map_filmstrip_activate_callback
static void _view_map_filmstrip_activate_callback(gpointer instance, gpointer user_data)
{
dt_view_t *self = (dt_view_t*)user_data;
dt_map_t *lib = (dt_map_t*)self->data;
double longitude, latitude;
int32_t imgid = 0;
if ((imgid=dt_view_filmstrip_get_activated_imgid(darktable.view_manager))>0)
{
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, imgid);
longitude = cimg->longitude;
latitude = cimg->latitude;
dt_image_cache_read_release(darktable.image_cache, cimg);
if(!isnan(longitude) && !isnan(latitude))
{
int zoom;
g_object_get(G_OBJECT(lib->map), "zoom", &zoom, NULL);
_view_map_center_on_location(self, longitude, latitude, zoom); // TODO: is it better to keep the zoom level or to zoom in? 16 is a nice close up.
}
}
}
示例15: dt_history_load_and_apply
int dt_history_load_and_apply(int imgid, gchar *filename, int history_only)
{
int res = 0;
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, imgid);
dt_image_t *img = dt_image_cache_write_get(darktable.image_cache, cimg);
if(img)
{
if(dt_exif_xmp_read(img, filename, history_only))
return 1;
/* if current image in develop reload history */
if(dt_dev_is_current_image(darktable.develop, imgid))
dt_dev_reload_history_items (darktable.develop);
dt_image_cache_write_release(darktable.image_cache, img, DT_IMAGE_CACHE_SAFE);
dt_image_cache_read_release(darktable.image_cache, img);
dt_mipmap_cache_remove(darktable.mipmap_cache, imgid);
}
return res;
}