示例#1
0
static void
export_button_clicked (GtkWidget *widget, gpointer user_data)
{
  char style[128];

  // Let's get the max dimension restriction if any...
  // TODO: pass the relevant values directly, not using the conf ...
  int max_width  = dt_conf_get_int ("plugins/lighttable/export/width");
  int max_height = dt_conf_get_int ("plugins/lighttable/export/height");
  char *format_name = dt_conf_get_string("plugins/lighttable/export/format_name");
  char *storage_name = dt_conf_get_string("plugins/lighttable/export/storage_name");
  int format_index = dt_imageio_get_index_of_format(dt_imageio_get_format_by_name(format_name));
  int storage_index = dt_imageio_get_index_of_storage(dt_imageio_get_storage_by_name(storage_name));
  g_free(format_name);
  g_free(storage_name);
  gboolean high_quality = dt_conf_get_bool("plugins/lighttable/export/high_quality_processing");
  char* tmp = dt_conf_get_string("plugins/lighttable/export/style");
  if (tmp)
  {
    g_strlcpy(style, tmp, sizeof(style));
    g_free(tmp);
  }

  int imgid = dt_view_get_image_to_act_on();
  GList *list = NULL;

  if (imgid != -1)
    list = g_list_append (list, GINT_TO_POINTER(imgid));
  else
    list = dt_collection_get_selected(darktable.collection, -1);

  dt_control_export(list, max_width, max_height, format_index, storage_index, high_quality,style);
}
示例#2
0
static void on_export_selection(gpointer instance,dt_control_image_enumerator_t * export_descriptor,
     gpointer user_data){
  lua_State* L = darktable.lua_state;
  dt_control_export_t *export_data= (dt_control_export_t*)export_descriptor->data;

  dt_imageio_module_storage_t  *mstorage  = dt_imageio_get_storage_by_index(export_data->storage_index);
  g_assert(mstorage);
  dt_imageio_module_data_t *fdata = mstorage->get_params(mstorage);
  luaA_push_typeid(L,mstorage->parameter_lua_type,fdata);
  mstorage->free_params(mstorage,fdata);

  dt_imageio_module_format_t  *mformat  = dt_imageio_get_format_by_index(export_data->format_index);
  g_assert(mformat);
  fdata = mformat->get_params(mformat);
  luaA_push_typeid(L,mformat->parameter_lua_type,fdata);
  mformat->free_params(mformat,fdata);

  GList * elt = export_descriptor->index;
  lua_newtable(L);
  while(elt)
  {
    luaA_push(L,dt_lua_image_t,&elt->data);
    luaL_ref(L,-2);
    elt = g_list_next(elt);
  }
  g_list_free(export_descriptor->index);
  export_descriptor->index =NULL;

  dt_lua_trigger_event("pre-export",3,3);

  // get the new storage data and the new storage
  luaL_getmetafield(L,-3,"__associated_object");
  mstorage = lua_touserdata(L,-1);
  lua_pop(L,1);
  fdata = mstorage->get_params(mstorage);
  luaL_getmetafield(L,-3,"__luaA_Type");
  luaA_Type storage_type = lua_tointeger(L,-1);
  lua_pop(L,1);
  luaA_to_typeid(L,storage_type,fdata,-3);
  mstorage->set_params(mstorage,fdata,mstorage->params_size(mstorage));
  mstorage->free_params(mstorage,fdata);
  export_data->storage_index = dt_imageio_get_index_of_storage(mstorage);

  // get the new format data and the new format
  luaL_getmetafield(L,-2,"__associated_object");
  mformat = lua_touserdata(L,-1);
  lua_pop(L,1);
  fdata = mformat->get_params(mformat);
  luaL_getmetafield(L,-2,"__luaA_Type");
  luaA_Type format_type = lua_tointeger(L,-1);
  lua_pop(L,1);
  luaA_to_typeid(L,format_type,fdata,-2);
  mformat->set_params(mformat,fdata,mstorage->params_size(mstorage));
  mformat->free_params(mformat,fdata);
  export_data->format_index = dt_imageio_get_index_of_format(mformat);

  // load the new list of images to process
  if(lua_isnoneornil(L,-1)) {lua_pop(L,3); return; }// everything already has been removed
  luaA_to(L,dt_lua_image_t,&export_descriptor->index,-1);

  lua_pop(L,1);
}