예제 #1
0
파일: rawprepare.c 프로젝트: PkmX/darktable
void gui_update(dt_iop_module_t *self)
{
  dt_iop_rawprepare_gui_data_t *g = (dt_iop_rawprepare_gui_data_t *)self->gui_data;
  dt_iop_rawprepare_params_t *p = (dt_iop_rawprepare_params_t *)self->params;

  for(int i = 0; i < 4; i++)
  {
    dt_bauhaus_slider_set_soft(g->black_level_separate[i], p->raw_black_level_separate[i]);
    dt_bauhaus_slider_set_default(g->black_level_separate[i], p->raw_black_level_separate[i]);
  }

  dt_bauhaus_slider_set_soft(g->white_point, p->raw_white_point);
  dt_bauhaus_slider_set_default(g->white_point, p->raw_white_point);

  if(self->default_enabled)
  {
    gtk_widget_show(g->box_raw);
    gtk_widget_hide(g->label_non_raw);
  }
  else
  {
    gtk_widget_hide(g->box_raw);
    gtk_widget_show(g->label_non_raw);
  }
}
예제 #2
0
void gui_update(dt_iop_module_t *self)
{
  dt_iop_rawprepare_gui_data_t *g = (dt_iop_rawprepare_gui_data_t *)self->gui_data;
  dt_iop_rawprepare_params_t *p = (dt_iop_rawprepare_params_t *)self->params;

  for(int i = 0; i < 4; i++)
  {
    dt_bauhaus_slider_set_soft(g->black_level_separate[i], p->raw_black_level_separate[i]);
    dt_bauhaus_slider_set_default(g->black_level_separate[i], p->raw_black_level_separate[i]);
  }

  dt_bauhaus_slider_set_soft(g->white_point, p->raw_white_point);
  dt_bauhaus_slider_set_default(g->white_point, p->raw_white_point);

  if(dt_conf_get_bool("plugins/darkroom/rawprepare/allow_editing_crop"))
  {
    for(int i = 0; i < 4; i++)
    {
      dt_bauhaus_slider_set_soft(g->crop[i], p->crop.array[i]);
      dt_bauhaus_slider_set_default(g->crop[i], p->crop.array[i]);
    }
  }

  if(self->default_enabled)
  {
    gtk_widget_show(g->box_raw);
    gtk_widget_hide(g->label_non_raw);
  }
  else
  {
    gtk_widget_hide(g->box_raw);
    gtk_widget_show(g->label_non_raw);
  }
}
예제 #3
0
void reload_defaults(dt_iop_module_t *module)
{
    // raw images need wb (to convert from uint16_t to float):
    if(dt_image_is_raw(&module->dev->image_storage))
    {
        module->default_enabled = 1;
        module->hide_enable_button = 1;
    }
    else module->default_enabled = 0;
    dt_iop_temperature_params_t tmp = (dt_iop_temperature_params_t)
    {
        5000.0, {1.0, 1.0, 1.0}
    };

    // get white balance coefficients, as shot
    char filename[DT_MAX_PATH_LEN];
    int ret=0;
    /* check if file is raw / hdr */
    if(dt_image_is_raw(&module->dev->image_storage))
    {
        gboolean from_cache = TRUE;
        dt_image_full_path(module->dev->image_storage.id, filename, DT_MAX_PATH_LEN, &from_cache);
        libraw_data_t *raw = libraw_init(0);

        ret = libraw_open_file(raw, filename);
        if(!ret)
        {
            module->default_enabled = 1;

            for(int k=0; k<3; k++) tmp.coeffs[k] = raw->color.cam_mul[k];
            if(tmp.coeffs[0] <= 0.0)
            {
                for(int k=0; k<3; k++) tmp.coeffs[k] = raw->color.pre_mul[k];
            }
            if(tmp.coeffs[0] == 0 || tmp.coeffs[1] == 0 || tmp.coeffs[2] == 0)
            {
                // could not get useful info, try presets:
                char makermodel[1024];
                char *model = makermodel;
                dt_colorspaces_get_makermodel_split(makermodel, 1024, &model,
                                                    module->dev->image_storage.exif_maker,
                                                    module->dev->image_storage.exif_model);
                for(int i=0; i<wb_preset_count; i++)
                {
                    if(!strcmp(wb_preset[i].make,  makermodel) &&
                            !strcmp(wb_preset[i].model, model))
                    {
                        // just take the first preset we find for this camera
                        for(int k=0; k<3; k++) tmp.coeffs[k] = wb_preset[i].channel[k];
                        break;
                    }
                }
                if(tmp.coeffs[0] == 0 || tmp.coeffs[1] == 0 || tmp.coeffs[2] == 0)
                {
                    // final security net: hardcoded default that fits most cams.
                    tmp.coeffs[0] = 2.0f;
                    tmp.coeffs[1] = 1.0f;
                    tmp.coeffs[2] = 1.5f;
                }
            }
            else
            {
                tmp.coeffs[0] /= tmp.coeffs[1];
                tmp.coeffs[2] /= tmp.coeffs[1];
                tmp.coeffs[1] = 1.0f;
            }
            // remember daylight wb used for temperature/tint conversion,
            // assuming it corresponds to CIE daylight (D65)
            if(module->gui_data)
            {
                dt_iop_temperature_gui_data_t *g = (dt_iop_temperature_gui_data_t *)module->gui_data;
                for(int c = 0; c < 3; c++)
                    g->daylight_wb[c] = raw->color.pre_mul[c];

                if(g->daylight_wb[0] == 1.0f &&
                        g->daylight_wb[1] == 1.0f &&
                        g->daylight_wb[2] == 1.0f)
                {
                    // if we didn't find anything for daylight wb, look for a wb preset with appropriate name.
                    // we're normalising that to be D65
                    char makermodel[1024];
                    char *model = makermodel;
                    dt_colorspaces_get_makermodel_split(makermodel, 1024, &model,
                                                        module->dev->image_storage.exif_maker,
                                                        module->dev->image_storage.exif_model);
                    for(int i=0; i<wb_preset_count; i++)
                    {
                        if(!strcmp(wb_preset[i].make,  makermodel) &&
                                !strcmp(wb_preset[i].model, model) &&
                                !strncasecmp(wb_preset[i].name, "daylight", 8))
                        {
                            for(int k=0; k<3; k++)
                                g->daylight_wb[k] = wb_preset[i].channel[k];
                            break;
                        }
                    }
                }
                float temp, tint, mul[3];
                for(int k=0; k<3; k++) mul[k] = g->daylight_wb[k]/tmp.coeffs[k];
                convert_rgb_to_k(mul, &temp, &tint);
                dt_bauhaus_slider_set_default(g->scale_k,    temp);
                dt_bauhaus_slider_set_default(g->scale_tint, tint);
            }

        }
        libraw_close(raw);
    }

    memcpy(module->params, &tmp, sizeof(dt_iop_temperature_params_t));
    memcpy(module->default_params, &tmp, sizeof(dt_iop_temperature_params_t));
}