Пример #1
0
static int write_image(lua_State *L)
{
  /* check that param 1 is a module_format_t */
  lua_getmetatable(L,1);
  lua_getfield(L,-1,"__module_type");
  if(strcmp(lua_tostring(L,-1),"format")) {
    return luaL_argerror(L,1,"not a format description");
  }
  lua_pop(L,1);
  lua_getfield(L,-1,"__luaA_Type");
  luaA_Type format_type = luaL_checkint(L,-1);
  lua_pop(L,1);
  lua_getfield(L,-1,"__associated_object");
  dt_imageio_module_format_t * format = lua_touserdata(L,-1);
  lua_pop(L,2);
  dt_imageio_module_data_t* fdata = format->get_params(format);
  luaA_to_typeid(L,format_type,fdata,1);

  /* check that param 2 is an image */
  dt_lua_image_t imgid;
  luaA_to(L,dt_lua_image_t,&imgid,2);

  /* check that param 3 is a string (filename) */
  const char * filename = luaL_checkstring(L,3);

  gboolean high_quality = dt_conf_get_bool("plugins/lighttable/export/high_quality_processing");
  lua_pushboolean(L,dt_imageio_export(imgid,filename,format,fdata,high_quality));
  format->free_params(format,fdata);
  return 1;
}
Пример #2
0
void luaA_struct_to_member_offset_typeid(lua_State* L, luaA_Type type, void* cstruct, size_t offset, int index) {

  struct_entry* se = luaA_hashtable_get(struct_table, luaA_type_name(type));
  if (se != NULL) {
    
    for(int j = 0; j < se->num_members; j++) {
    if (se->members[j]->offset == offset) {
      struct_member_entry* sme = se->members[j];
      return luaA_to_typeid(L, sme->type, cstruct+sme->offset, index);
    }
    }
    
    lua_pushfstring(L, "luaA_struct_to_member: Member offset '%i' not registered for struct '%s'!", offset, luaA_type_name(type));
    lua_error(L);  
  }
  
  lua_pushfstring(L, "luaA_struct_to_member: Struct '%s' not registered!", luaA_type_name(type));
  lua_error(L);
}
Пример #3
0
void luaA_struct_to_member_name_typeid(lua_State* L, luaA_Type type, void* cstruct, const char* member, int index) {

  struct_entry* se = luaA_hashtable_get(struct_table, luaA_type_name(type));
  if (se != NULL) {
    
    for(int j = 0; j < se->num_members; j++) {
    if (strcmp(se->members[j]->name, member) == 0) {
      struct_member_entry* sme = se->members[j];
      return luaA_to_typeid(L, sme->type, cstruct+sme->offset, index);
    }
    }
    
    lua_pushfstring(L, "luaA_struct_to_member_name: Member '%s' not registered for struct '%s'!", member, luaA_type_name(type));
    lua_error(L);  
  }
  
  lua_pushfstring(L, "luaA_struct_to_member_name: Struct '%s' not registered!", luaA_type_name(type));
  lua_error(L);
}
Пример #4
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);
}