00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _UFRAW_H
00015 #define _UFRAW_H
00016
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020
00021 #include "uf_glib.h"
00022 #include "ufobject.h"
00023
00024 #include "nikon_curve.h"
00025 #include "uf_progress.h"
00026
00027
00028 #ifndef LIM
00029 #define LIM(x,min,max) MAX(min,MIN(x,max))
00030 #endif
00031
00032 #define MAXOUT 255
00033
00034 #define max_curves 20
00035 #define max_anchors 20
00036 #define max_profiles 20
00037 #define max_path 200
00038 #define max_name 80
00039 #define max_adjustments 3
00040
00041
00042 #define NULLF -10000.0
00043
00044
00045
00046
00047 enum { disabled_state, enabled_state, apply_state };
00048
00049 extern const char uf_spot_wb[];
00050 extern const char uf_manual_wb[];
00051 extern const char uf_camera_wb[];
00052 extern const char uf_auto_wb[];
00053
00054
00055
00056
00057
00058 extern UFName ufWB;
00059 extern UFName ufPreset;
00060 extern UFName ufWBFineTuning;
00061 extern UFName ufTemperature;
00062 extern UFName ufGreen;
00063 extern UFName ufChannelMultipliers;
00064 extern UFName ufLensfunAuto;
00065 extern UFName ufLensfun;
00066 extern UFName ufCameraModel;
00067 extern UFName ufLensModel;
00068 extern UFName ufFocalLength;
00069 extern UFName ufAperture;
00070 extern UFName ufDistance;
00071 extern UFName ufTCA;
00072 extern UFName ufVignetting;
00073 extern UFName ufDistortion;
00074 extern UFName ufModel;
00075 extern UFName ufLensGeometry;
00076 extern UFName ufTargetLensGeometry;
00077 extern UFName ufRawImage;
00078 extern UFName ufRawResources;
00079 extern UFName ufCommandLine;
00080
00081 #ifdef __cplusplus
00082 extern "C" {
00083 #endif // __cplusplus
00084
00085 UFObject *ufraw_image_new();
00086 #ifdef HAVE_LENSFUN
00087 UFObject *ufraw_lensfun_new();
00088 void ufraw_lensfun_init(UFObject *lensfun);
00089 struct lfDatabase *ufraw_lensfun_db();
00090 const struct lfCamera *ufraw_lensfun_camera(const UFObject *lensfun);
00091 void ufraw_lensfun_set_camera(UFObject *lensfun, const struct lfCamera *camera);
00092 const struct lfLens *ufraw_lensfun_interpolation_lens(const UFObject *lensfun);
00093 void ufraw_lensfun_set_lens(UFObject *lensfun, const struct lfLens *lens);
00094 #endif
00095 struct ufraw_struct *ufraw_image_get_data(UFObject *obj);
00096 void ufraw_image_set_data(UFObject *obj, struct ufraw_struct *uf);
00097 UFObject *ufraw_resources_new();
00098 UFObject *ufraw_command_line_new();
00099
00100 #ifdef __cplusplus
00101 }
00102 #endif // __cplusplus
00103
00104 enum { rgb_histogram, r_g_b_histogram, luminosity_histogram, value_histogram,
00105 saturation_histogram };
00106 enum { linear_histogram, log_histogram };
00107
00108
00109 enum { ahd_interpolation, vng_interpolation, four_color_interpolation,
00110 ppg_interpolation, bilinear_interpolation, none_interpolation,
00111 half_interpolation, obsolete_eahd_interpolation, num_interpolations };
00112 enum { no_id, also_id, only_id, send_id };
00113 enum { manual_curve, linear_curve, custom_curve, camera_curve };
00114 enum { in_profile, out_profile, display_profile, profile_types};
00115 enum { raw_expander, live_expander, expander_count };
00116 enum { ppm_type, ppm16_deprecated_type, tiff_type, tiff16_deprecated_type,
00117 jpeg_type, png_type, png16_deprecated_type,
00118 embedded_jpeg_type, embedded_png_type, fits_type, num_types };
00119 enum { clip_details, restore_lch_details, restore_hsv_details,
00120 restore_types };
00121 enum { digital_highlights, film_highlights, highlights_types };
00122 typedef enum { display_developer, file_developer, auto_developer }
00123 DeveloperMode;
00124 typedef enum { perceptual_intent, relative_intent, saturation_intent,
00125 absolute_intent, disable_intent } Intent;
00126 typedef enum { ufraw_raw_phase, ufraw_first_phase, ufraw_transform_phase,
00127 ufraw_develop_phase, ufraw_display_phase, ufraw_phases_num } UFRawPhase;
00128 typedef enum { grayscale_none, grayscale_lightness, grayscale_luminance,
00129 grayscale_value, grayscale_mixer } GrayscaleMode;
00130
00131 typedef struct {
00132 const char *make;
00133 const char *model;
00134 const char *name;
00135 int tuning;
00136 double channel[4];
00137 } wb_data;
00138
00139 typedef struct {
00140 double adjustment;
00141 double hue;
00142 double hueWidth;
00143 } lightness_adjustment;
00144
00145 typedef struct {
00146 DeveloperMode mode;
00147 unsigned rgbMax, max, exposure, colors, useMatrix;
00148 int restoreDetails, clipHighlights;
00149 int rgbWB[4], colorMatrix[3][4];
00150 double gamma, linear;
00151 char profileFile[profile_types][max_path];
00152 void *profile[profile_types];
00153 Intent intent[profile_types];
00154 gboolean updateTransform;
00155 void *colorTransform;
00156 void *working2displayTransform;
00157 void *rgbtolabTransform;
00158 double saturation;
00159 #ifdef UFRAW_CONTRAST
00160 double contrast;
00161 #endif
00162 CurveData baseCurveData, luminosityCurveData;
00163 guint16 gammaCurve[0x10000];
00164 void *luminosityProfile;
00165 void *TransferFunction[3];
00166 void *saturationProfile;
00167 void *adjustmentProfile;
00168 GrayscaleMode grayscaleMode;
00169 double grayscaleMixer[3];
00170 lightness_adjustment lightnessAdjustment[max_adjustments];
00171 } developer_data;
00172
00173 typedef guint16 ufraw_image_type[4];
00174
00175 typedef struct {
00176 char name[max_name];
00177 char file[max_path];
00178 char productName[max_name];
00179 double gamma, linear;
00180 int BitDepth;
00181 } profile_data;
00182
00183 typedef struct {
00184 gint x;
00185 gint y;
00186 gint width;
00187 gint height;
00188 } UFRectangle;
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 typedef struct {
00219
00220 int version;
00221
00222
00223 UFObject *ufobject;
00224
00225
00226 double threshold;
00227 double hotpixel;
00228 #ifdef UFRAW_CONTRAST
00229 double contrast;
00230 #endif
00231 double exposure, saturation, black;
00232 int ExposureNorm;
00233 int restoreDetails, clipHighlights;
00234 int autoExposure, autoBlack, autoCrop;
00235 int BaseCurveIndex, BaseCurveCount;
00236 CurveData BaseCurve[max_curves];
00237 int curveIndex, curveCount;
00238 CurveData curve[max_curves];
00239 int profileIndex[profile_types], profileCount[profile_types];
00240 profile_data profile[profile_types][max_profiles];
00241 Intent intent[profile_types];
00242 int interpolation;
00243 int smoothing;
00244 char darkframeFile[max_path];
00245 struct ufraw_struct *darkframe;
00246 int CropX1, CropY1, CropX2, CropY2;
00247 int orientation;
00248 double rotationAngle;
00249 int lightnessAdjustmentCount;
00250 lightness_adjustment lightnessAdjustment[max_adjustments];
00251 int grayscaleMode;
00252 double grayscaleMixer[3];
00253 double despeckleWindow[3];
00254 double despeckleDecay[3];
00255 double despecklePasses[3];
00256
00257
00258 char inputFilename[max_path], outputFilename[max_path],
00259 outputPath[max_path];
00260 char inputURI[max_path], inputModTime[max_name];
00261 int type, compression, createID, embedExif, progressiveJPEG;
00262 int shrink, size;
00263 gboolean overwrite, losslessCompress, embeddedImage;
00264 gboolean rotate;
00265
00266
00267 double Zoom;
00268 gboolean LockAspect;
00269 int saveConfiguration;
00270 int histogram, liveHistogramScale;
00271 int rawHistogramScale;
00272 int expander[expander_count];
00273 gboolean overExp, underExp, blinkOverUnder;
00274 gboolean RememberOutputPath;
00275 gboolean WindowMaximized;
00276 int drawLines;
00277 char curvePath[max_path];
00278 char profilePath[max_path];
00279 gboolean silent;
00280 char remoteGimpCommand[max_path];
00281
00282
00283 int CameraOrientation;
00284 float iso_speed, shutter, aperture, focal_len, subject_distance;
00285 char exifSource[max_name], isoText[max_name], shutterText[max_name],
00286 apertureText[max_name], focalLenText[max_name],
00287 focalLen35Text[max_name], lensText[max_name],
00288 flashText[max_name], whiteBalanceText[max_name];
00289 char timestampText[max_name], make[max_name], model[max_name];
00290 time_t timestamp;
00291
00292 char real_make[max_name], real_model[max_name];
00293 } conf_data;
00294
00295 typedef struct {
00296 guint8 *buffer;
00297 int height, width, depth, rowstride;
00298
00299
00300
00301
00302
00303 guint32 valid;
00304 gboolean rgbg;
00305 gboolean invalidate_event;
00306 } ufraw_image_data;
00307
00308 typedef struct ufraw_struct {
00309 int status;
00310 char *message;
00311 char filename[max_path];
00312 int initialHeight, initialWidth, rgbMax, colors, raw_color, useMatrix;
00313 int rotatedHeight, rotatedWidth;
00314 int autoCropHeight, autoCropWidth;
00315 gboolean LoadingID;
00316 gboolean WBDirty;
00317 float rgb_cam[3][4];
00318 ufraw_image_data Images[ufraw_phases_num];
00319 ufraw_image_data thumb;
00320 void *raw;
00321 gboolean HaveFilters;
00322 void *unzippedBuf;
00323 gsize unzippedBufLen;
00324 developer_data *developer;
00325 developer_data *AutoDeveloper;
00326 guint8 *displayProfile;
00327 gint displayProfileSize;
00328 conf_data *conf;
00329 guchar *inputExifBuf;
00330 guint inputExifBufLen;
00331 guchar *outputExifBuf;
00332 guint outputExifBufLen;
00333 int gimpImage;
00334 int *RawHistogram;
00335 int RawChanMul[4];
00336 int RawCount;
00337 #ifdef HAVE_LENSFUN
00338 int modFlags;
00339 struct lfModifier *TCAmodifier;
00340 struct lfModifier *modifier;
00341 #endif
00342 int hotpixels;
00343 gboolean mark_hotpixels;
00344 unsigned raw_multiplier;
00345 gboolean wb_presets_make_model_match;
00346 } ufraw_data;
00347
00348 extern const conf_data conf_default;
00349 extern const wb_data wb_preset[];
00350 extern const int wb_preset_count;
00351 extern const char raw_ext[];
00352 extern const char *file_type[];
00353
00354
00355
00356 extern char *ufraw_binary;
00357
00358 #ifdef __cplusplus
00359 extern "C" {
00360 #endif
00361
00362
00363 ufraw_data *ufraw_open(char *filename);
00364 int ufraw_config(ufraw_data *uf, conf_data *rc, conf_data *conf,conf_data *cmd);
00365 int ufraw_load_raw(ufraw_data *uf);
00366 int ufraw_load_darkframe(ufraw_data *uf);
00367 void ufraw_developer_prepare(ufraw_data *uf, DeveloperMode mode);
00368 int ufraw_convert_image(ufraw_data *uf);
00369 ufraw_image_data *ufraw_get_image(ufraw_data *uf, UFRawPhase phase,
00370 gboolean bufferok);
00371 ufraw_image_data *ufraw_convert_image_area(ufraw_data *uf, unsigned saidx,
00372 UFRawPhase phase);
00373 void ufraw_close(ufraw_data *uf);
00374 void ufraw_flip_orientation(ufraw_data *uf, int flip);
00375 void ufraw_flip_image(ufraw_data *uf, int flip);
00376 void ufraw_invalidate_layer(ufraw_data *uf, UFRawPhase phase);
00377 void ufraw_invalidate_tca_layer(ufraw_data *uf);
00378 void ufraw_invalidate_hotpixel_layer(ufraw_data *uf);
00379 void ufraw_invalidate_denoise_layer(ufraw_data *uf);
00380 void ufraw_invalidate_darkframe_layer(ufraw_data *uf);
00381 void ufraw_invalidate_despeckle_layer(ufraw_data *uf);
00382 void ufraw_invalidate_whitebalance_layer(ufraw_data *uf);
00383 void ufraw_invalidate_smoothing_layer(ufraw_data *uf);
00384 int ufraw_set_wb(ufraw_data *uf);
00385 void ufraw_auto_expose(ufraw_data *uf);
00386 void ufraw_auto_black(ufraw_data *uf);
00387 void ufraw_auto_curve(ufraw_data *uf);
00388 void ufraw_normalize_rotation(ufraw_data *uf);
00389 void ufraw_unnormalize_rotation(ufraw_data *uf);
00390 void ufraw_get_image_dimensions(ufraw_data *uf);
00391
00392 void ufraw_get_scaled_crop(ufraw_data *uf, UFRectangle *crop);
00393
00394 UFRectangle ufraw_image_get_subarea_rectangle(ufraw_image_data *img,
00395 unsigned saidx);
00396 unsigned ufraw_img_get_subarea_idx (ufraw_image_data *img, int x, int y);
00397
00398
00399 char *ufraw_get_message(ufraw_data *uf);
00400
00401 void ufraw_message_init(ufraw_data *uf);
00402 void ufraw_message_reset(ufraw_data *uf);
00403 void ufraw_set_error(ufraw_data *uf, const char *format, ...);
00404 void ufraw_set_warning(ufraw_data *uf, const char *format, ...);
00405 void ufraw_set_info(ufraw_data *uf, const char *format, ...);
00406 int ufraw_get_status(ufraw_data *uf);
00407 int ufraw_is_error(ufraw_data *uf);
00408
00409 char *ufraw_message(int code, const char *format, ...);
00410 void ufraw_batch_messenger(char *message);
00411
00412
00413 int ufraw_preview(ufraw_data *uf, conf_data *rc, int plugin,
00414 long (*save_func)());
00415 void ufraw_focus(void *window, gboolean focus);
00416 void ufraw_messenger(char *message, void *parentWindow);
00417
00418
00419 const char *uf_get_home_dir();
00420 void uf_init_locale(const char *exename);
00421 char *uf_file_set_type(const char *filename, const char *type);
00422 char *uf_file_set_absolute(const char *filename);
00423 char *uf_set_locale_C();
00424 void uf_reset_locale(char *locale);
00425 char *uf_markup_buf(char *buffer, const char *format, ...);
00426 double profile_default_linear(profile_data *p);
00427 double profile_default_gamma(profile_data *p);
00428 void Temperature_to_RGB(double T, double RGB[3]);
00429 void RGB_to_Temperature(double RGB[3], double *T, double *Green);
00430 int curve_load(CurveData *cp, char *filename);
00431 int curve_save(CurveData *cp, char *filename);
00432 char *curve_buffer(CurveData *cp);
00433
00434 int ptr_array_insert_sorted (GPtrArray *array, const void *item, GCompareFunc compare);
00435 int ptr_array_find_sorted (const GPtrArray *array, const void *item, GCompareFunc compare);
00436 void ptr_array_insert_index (GPtrArray *array, const void *item, int index);
00437
00438
00439 int conf_load(conf_data *c, const char *confFilename);
00440 void conf_file_load(conf_data *conf, char *confFilename);
00441 int conf_save(conf_data *c, char *confFilename, char **confBuffer);
00442
00443 void conf_init (conf_data *c);
00444
00445 void conf_copy_image(conf_data *dst, const conf_data *src);
00446
00447 void conf_copy_transform(conf_data *dst, const conf_data *src);
00448
00449 void conf_copy_save(conf_data *dst, const conf_data *src);
00450 int conf_set_cmd(conf_data *conf, const conf_data *cmd);
00451 int ufraw_process_args(int *argc, char ***argv, conf_data *cmd, conf_data *rc);
00452
00453
00454
00455 void uf_rgb_to_cielch(gint64 rgb[3], float lch[3]);
00456
00457 void uf_cielch_to_rgb(float lch[3], gint64 rgb[3]);
00458 void uf_raw_to_cielch(const developer_data *d,
00459 const guint16 raw[4], float lch[3]);
00460 developer_data *developer_init();
00461 void developer_destroy(developer_data *d);
00462 void developer_profile(developer_data *d, int type, profile_data *p);
00463 void developer_display_profile(developer_data *d,
00464 unsigned char *profile, int size, char productName[]);
00465 void developer_prepare(developer_data *d, conf_data *conf,
00466 int rgbMax, float rgb_cam[3][4], int colors, int useMatrix,
00467 DeveloperMode mode);
00468 void develop(void *po, guint16 pix[4], developer_data *d, int mode, int count);
00469 void develop_display(void *pout, void *pin, developer_data *d, int count);
00470 void develop_linear(guint16 in[4], guint16 out[3], developer_data *d);
00471
00472
00473 long ufraw_save_now(ufraw_data *uf, void *widget);
00474 long ufraw_send_to_gimp(ufraw_data *uf);
00475
00476
00477 int ufraw_write_image(ufraw_data *uf);
00478 void ufraw_write_image_data(
00479 ufraw_data *uf, void * volatile out,
00480 const UFRectangle *Crop, int bitDepth, int grayscaleMode,
00481 int (*row_writer)(ufraw_data *, void * volatile, void *, int, int, int, int, int));
00482
00483
00484 long ufraw_delete(void *widget, ufraw_data *uf);
00485
00486
00487 int ufraw_read_embedded(ufraw_data *uf);
00488 int ufraw_convert_embedded(ufraw_data *uf);
00489 int ufraw_write_embedded(ufraw_data *uf);
00490
00491
00492 void ufraw_chooser(conf_data *conf, conf_data *rc, conf_data *cmd,
00493 const char *defPath);
00494
00495
00496 void ufraw_icons_init();
00497
00498
00499 int ufraw_exif_read_input(ufraw_data *uf);
00500 int ufraw_exif_prepare_output(ufraw_data *uf);
00501 int ufraw_exif_write(ufraw_data *uf);
00502
00503 #ifdef __cplusplus
00504 }
00505 #endif
00506
00507
00508 #define UFRAW_SUCCESS 0
00509
00510
00511
00512
00513
00514 #define UFRAW_DCRAW_SET_LOG 4
00515 #define UFRAW_ERROR 100
00516 #define UFRAW_CANCEL 101
00517 #define UFRAW_RC_VERSION 103
00518 #define UFRAW_WARNING 104
00519 #define UFRAW_MESSAGE 105
00520 #define UFRAW_SET_ERROR 200
00521 #define UFRAW_SET_WARNING 201
00522 #define UFRAW_SET_LOG 202
00523 #define UFRAW_GET_ERROR 203
00524 #define UFRAW_GET_WARNING 204
00525 #define UFRAW_GET_LOG 205
00526 #define UFRAW_BATCH_MESSAGE 206
00527 #define UFRAW_INTERACTIVE_MESSAGE 207
00528 #define UFRAW_REPORT 208
00529 #define UFRAW_CLEAN 209
00530 #define UFRAW_RESET 210
00531 #define UFRAW_SET_PARENT 211
00532
00533 #endif