f.repair.cc (fotoxx-23.0) | : | f.repair.cc (fotoxx-23.1) | ||
---|---|---|---|---|
/******************************************************************************* * | /******************************************************************************* * | |||
Fotoxx edit photos and manage collections | Fotoxx - edit photos and manage collections | |||
Copyright 2007-2023 Michael Cornelison | Copyright 2007-2023 Michael Cornelison | |||
source code URL: https://kornelix.net | source code URL: https://kornelix.net | |||
contact: mkornelix@gmail.com | contact: mkornelix@gmail.com | |||
This program is free software: you can redistribute it and/or modify | This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 3 of the License, or | the Free Software Foundation, either version 3 of the License, or | |||
(at your option) any later version. See https://www.gnu.org/licenses | (at your option) any later version. See https://www.gnu.org/licenses | |||
skipping to change at line 65 | skipping to change at line 65 | |||
namespace sharpen_names | namespace sharpen_names | |||
{ | { | |||
int Eww, Ehh; // image dimensions | int Eww, Ehh; // image dimensions | |||
int UM_radius, UM_amount, UM_thresh; | int UM_radius, UM_amount, UM_thresh; | |||
int GR_amount, GR_thresh; | int GR_amount, GR_thresh; | |||
int KH_radius; | int KH_radius; | |||
int MD_radius, MD_dark, MD_light, *MD_britemap; | int MD_radius, MD_dark, MD_light, *MD_britemap; | |||
float RL_radius; | float RL_radius; | |||
int RL_iters; | int RL_iters; | |||
char sharp_function[8] = ""; | ch sharp_function[8] = ""; | |||
int brhood_radius; | int brhood_radius; | |||
float brhood_kernel[200][200]; // up to radius = 99 | float brhood_kernel[200][200]; // up to radius = 99 | |||
char brhood_method; // g = gaussian, f = flat distribution | ch brhood_method; // g = gaussian, f = flat distribution | |||
float *brhood_brightness = 0; // neighborhood brightness per pixel | float *brhood_brightness = 0; // neighborhood brightness per pixel | |||
int BRH_radius = 0; // radius base for above calculation | int BRH_radius = 0; // radius base for above calculation | |||
VOL int sharp_cancel, brhood_cancel; // avoid GCC optimizing code away | VOL int sharp_cancel, brhood_cancel; // avoid GCC optimizing code away | |||
editfunc EFsharp; | editfunc EFsharp; | |||
char edit_hist[200]; | ch edit_hist[200]; | |||
} | } | |||
// menu function | // menu function | |||
void m_sharpen(GtkWidget *, cchar *menu) | void m_sharpen(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace sharpen_names; | using namespace sharpen_names; | |||
int sharp_dialog_event(zdialog *zd, cchar *event); | int sharp_dialog_event(zdialog *zd, ch *event); | |||
void * sharp_thread(void *); | void * sharp_thread(void *); | |||
int ii; | int ii; | |||
F1_help_topic = "sharpen"; | F1_help_topic = "sharpen"; | |||
Plog(1,"m_sharpen \n"); | Plog(1,"m_sharpen \n"); | |||
EFsharp.menuname = "Sharpen"; | EFsharp.menuname = "Sharpen"; | |||
EFsharp.menufunc = m_sharpen; | EFsharp.menufunc = m_sharpen; | |||
EFsharp.Farea = 2; // select area usable | EFsharp.Farea = 2; // select area usable | |||
skipping to change at line 217 | skipping to change at line 217 | |||
zdialog_fetch(zd,"RL",ii); | zdialog_fetch(zd,"RL",ii); | |||
if (ii) strcpy(sharp_function,"RL"); | if (ii) strcpy(sharp_function,"RL"); | |||
zdialog_run(zd,sharp_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,sharp_dialog_event,"save"); // run dialog - parallel | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int sharp_dialog_event(zdialog *zd, cchar *event) // reworked for script files | int sharp_dialog_event(zdialog *zd, ch *event) // reworked for script files | |||
{ | { | |||
using namespace sharpen_names; | using namespace sharpen_names; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"focus")) return 1; | if (strmatch(event,"focus")) return 1; | |||
zdialog_fetch(zd,"radiusUM",UM_radius); // get all parameters | zdialog_fetch(zd,"radiusUM",UM_radius); // get all parameters | |||
zdialog_fetch(zd,"amountUM",UM_amount); | zdialog_fetch(zd,"amountUM",UM_amount); | |||
zdialog_fetch(zd,"threshUM",UM_thresh); | zdialog_fetch(zd,"threshUM",UM_thresh); | |||
zdialog_fetch(zd,"amountGR",GR_amount); | zdialog_fetch(zd,"amountGR",GR_amount); | |||
skipping to change at line 246 | skipping to change at line 246 | |||
if (strmatch(event,"apply")) zd->zstat = 2; // from script file | if (strmatch(event,"apply")) zd->zstat = 2; // from script file | |||
if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | |||
sharp_cancel = 0; | sharp_cancel = 0; | |||
if (zd->zstat) | if (zd->zstat) | |||
{ | { | |||
thread_wait(); | thread_wait(); | |||
if (! zdialog_valid(zd)) goto cancel; | ||||
// user escape 23.1 | ||||
if (zd->zstat == 1) { // [reset] | if (zd->zstat == 1) { // [reset] | |||
zd->zstat = 0; | zd->zstat = 0; | |||
edit_reset(); | edit_reset(); | |||
return 1; | return 1; | |||
} | } | |||
if (zd->zstat == 2) { // [apply] | if (zd->zstat == 2) { // [apply] | |||
zd->zstat = 0; | zd->zstat = 0; | |||
edit_reset(); | edit_reset(); | |||
if (*sharp_function) thread_signal(); // start thread function | if (*sharp_function) thread_signal(); // start thread function | |||
else zmessageACK(Mwin,"no slection"); // no choice made | else zmessageACK(Mwin,"no slection"); // no choice made | |||
return 1; | return 1; | |||
} | } | |||
if (zd->zstat == 3) { // [OK] | if (zd->zstat == 3) { // [OK] | |||
edit_addhist(edit_hist); // record edit history 22.50 | edit_addhist(edit_hist); // record edit history 22.50 | |||
edit_done(0); // done | edit_done(0); // done | |||
if (brhood_brightness) zfree(brhood_brightness); | if (brhood_brightness) zfree(brhood_brightness); | |||
brhood_brightness = 0; | brhood_brightness = 0; | |||
return 1; | return 1; | |||
} | } | |||
cancel: | ||||
sharp_cancel = 1; // [cancel] or [x] | sharp_cancel = 1; // [cancel] or [x] | |||
edit_cancel(0); // discard edit | edit_cancel(0); // discard edit | |||
if (brhood_brightness) zfree(brhood_brightness); | if (brhood_brightness) zfree(brhood_brightness); | |||
brhood_brightness = 0; | brhood_brightness = 0; | |||
return 1; | return 1; | |||
} | } | |||
if (strmatch(event,"blendwidth")) thread_signal(); | if (strmatch(event,"blendwidth")) thread_signal(); | |||
if (strmatch(event,"paint")) thread_signal(); | if (strmatch(event,"paint")) thread_signal(); | |||
skipping to change at line 345 | skipping to change at line 348 | |||
} | } | |||
// ----------------------------------------------------------------------------- - | // ----------------------------------------------------------------------------- - | |||
// image sharpen function using unsharp mask | // image sharpen function using unsharp mask | |||
int sharp_UM_thread() | int sharp_UM_thread() | |||
{ | { | |||
using namespace sharpen_names; | using namespace sharpen_names; | |||
void britehood(int radius, char method); // compute neighborhood brightness | void britehood(int radius, ch method); // compute neighborhood brightness | |||
void * sharp_UM_wthread(void *arg); | void * sharp_UM_wthread(void *arg); | |||
int64 cc; | int64 cc; | |||
if (! brhood_brightness) { | if (! brhood_brightness) { | |||
cc = Eww * Ehh * sizeof(float); | cc = Eww * Ehh * sizeof(float); | |||
brhood_brightness = (float *) zmalloc(cc,"sharpen"); | brhood_brightness = (float *) zmalloc(cc,"sharpen"); | |||
BRH_radius = 0; | BRH_radius = 0; | |||
} | } | |||
skipping to change at line 1120 | skipping to change at line 1123 | |||
return; | return; | |||
} | } | |||
// ----------------------------------------------------------------------------- - | // ----------------------------------------------------------------------------- - | |||
// Compute the mean brightness of all pixel neighborhoods, | // Compute the mean brightness of all pixel neighborhoods, | |||
// using a Gaussian or a flat distribution for the weightings. | // using a Gaussian or a flat distribution for the weightings. | |||
// If a select area is active, only inside pixels are calculated. | // If a select area is active, only inside pixels are calculated. | |||
// The flat method is 10-100x faster than the Gaussian method. | // The flat method is 10-100x faster than the Gaussian method. | |||
void britehood(int radius, char method) | void britehood(int radius, ch method) | |||
{ | { | |||
using namespace sharpen_names; | using namespace sharpen_names; | |||
void * brhood_wthread(void *arg); | void * brhood_wthread(void *arg); | |||
int rad, radflat2, dx, dy; | int rad, radflat2, dx, dy; | |||
float kern; | float kern; | |||
brhood_radius = radius; | brhood_radius = radius; | |||
brhood_method = method; | brhood_method = method; | |||
skipping to change at line 1273 | skipping to change at line 1276 | |||
} | } | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// blur image steering function - choose from multiple blur functions | // blur image steering function - choose from multiple blur functions | |||
void m_blur(GtkWidget *, cchar *menu) | void m_blur(GtkWidget *, ch *menu) | |||
{ | { | |||
int blur_dialog_event(zdialog *zd, cchar *event); | int blur_dialog_event(zdialog *zd, ch *event); | |||
zdialog *zd; | zdialog *zd; | |||
F1_help_topic = "blur"; | F1_help_topic = "blur"; | |||
Plog(1,"m_blur \n"); | Plog(1,"m_blur \n"); | |||
/*** | /*** | |||
____________________________________________________________________ | ____________________________________________________________________ | |||
| Blur Image | | | Blur Image | | |||
skipping to change at line 1323 | skipping to change at line 1326 | |||
zdialog_stuff(zd,"paint",0); | zdialog_stuff(zd,"paint",0); | |||
zdialog_stuff(zd,"background",0); | zdialog_stuff(zd,"background",0); | |||
zdialog_stuff(zd,"motion",0); | zdialog_stuff(zd,"motion",0); | |||
zdialog_run(zd,blur_dialog_event,"save"); | zdialog_run(zd,blur_dialog_event,"save"); | |||
return; | return; | |||
} | } | |||
// dialog event and completion function | // dialog event and completion function | |||
int blur_dialog_event(zdialog *zd, cchar *event) | int blur_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
void m_blur_normal(GtkWidget *, cchar *menu); | void m_blur_normal(GtkWidget *, ch *menu); | |||
void m_blur_radial(GtkWidget *, cchar *menu); | void m_blur_radial(GtkWidget *, ch *menu); | |||
void m_blur_directed(GtkWidget *, cchar *menu); | void m_blur_directed(GtkWidget *, ch *menu); | |||
void m_blur_graduated(GtkWidget *, cchar *menu); | void m_blur_graduated(GtkWidget *, ch *menu); | |||
void m_blur_paint(GtkWidget *, cchar *menu); | void m_blur_paint(GtkWidget *, ch *menu); | |||
void m_blur_background(GtkWidget *, cchar *menu); | void m_blur_background(GtkWidget *, ch *menu); | |||
void m_blur_motion(GtkWidget *, cchar *menu); | void m_blur_motion(GtkWidget *, ch *menu); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (zd->zstat) { | if (zd->zstat) { | |||
zdialog_free(zd); | zdialog_free(zd); | |||
return 1; | return 1; | |||
} | } | |||
if (strmatch(event,"normal")) m_blur_normal(0,0); | if (strmatch(event,"normal")) m_blur_normal(0,0); | |||
if (strmatch(event,"radial")) m_blur_radial(0,0); | if (strmatch(event,"radial")) m_blur_radial(0,0); | |||
skipping to change at line 1369 | skipping to change at line 1372 | |||
{ | { | |||
editfunc EFblur; | editfunc EFblur; | |||
VOL int Fcancel; | VOL int Fcancel; | |||
PXM *E2pxm; | PXM *E2pxm; | |||
int Eww, Ehh; | int Eww, Ehh; | |||
float blur_radius; // blur radius | float blur_radius; // blur radius | |||
float blur_weight[1415]; // blur radius limit 999 | float blur_weight[1415]; // blur radius limit 999 | |||
} | } | |||
void m_blur_normal(GtkWidget *, cchar *menu) | void m_blur_normal(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace blur_normal_names; | using namespace blur_normal_names; | |||
int blur_normal_dialog_event(zdialog *zd, cchar *event); | int blur_normal_dialog_event(zdialog *zd, ch *event); | |||
void * blur_normal_thread(void *); | void * blur_normal_thread(void *); | |||
F1_help_topic = "blur"; | F1_help_topic = "blur"; | |||
Plog(1,"m_blur_normal \n"); | Plog(1,"m_blur_normal \n"); | |||
EFblur.menuname = "Blur Normal"; | EFblur.menuname = "Blur Normal"; | |||
EFblur.menufunc = m_blur_normal; | EFblur.menufunc = m_blur_normal; | |||
EFblur.Farea = 2; // select area usable | EFblur.Farea = 2; // select area usable | |||
EFblur.threadfunc = blur_normal_thread; // thread function | EFblur.threadfunc = blur_normal_thread; // thread function | |||
skipping to change at line 1420 | skipping to change at line 1423 | |||
blur_radius = 10; | blur_radius = 10; | |||
zdialog_restore_inputs(zd); | zdialog_restore_inputs(zd); | |||
zdialog_run(zd,blur_normal_dialog_event,"save"); // run dialog | zdialog_run(zd,blur_normal_dialog_event,"save"); // run dialog | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int blur_normal_dialog_event(zdialog * zd, cchar *event) | int blur_normal_dialog_event(zdialog * zd, ch *event) | |||
{ | { | |||
using namespace blur_normal_names; | using namespace blur_normal_names; | |||
void blur_mousefunc(); | void blur_mousefunc(); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | |||
zdialog_fetch(zd,"blur_radius",blur_radius); | zdialog_fetch(zd,"blur_radius",blur_radius); | |||
skipping to change at line 1658 | skipping to change at line 1661 | |||
{ | { | |||
editfunc EFblur; | editfunc EFblur; | |||
VOL int Fcancel; | VOL int Fcancel; | |||
PXM *E2pxm; | PXM *E2pxm; | |||
int Eww, Ehh; | int Eww, Ehh; | |||
int RBrad, RBlen; // radial blur radius, length | int RBrad, RBlen; // radial blur radius, length | |||
int Cx, Cy; // image center of radial blur | int Cx, Cy; // image center of radial blur | |||
} | } | |||
void m_blur_radial(GtkWidget *, cchar *menu) | void m_blur_radial(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace blur_radial_names; | using namespace blur_radial_names; | |||
int blur_radial_dialog_event(zdialog *zd, cchar *event); | int blur_radial_dialog_event(zdialog *zd, ch *event); | |||
void blur_radial_mousefunc(); | void blur_radial_mousefunc(); | |||
void * blur_radial_thread(void *); | void * blur_radial_thread(void *); | |||
F1_help_topic = "blur"; | F1_help_topic = "blur"; | |||
Plog(1,"m_blur_radial \n"); | Plog(1,"m_blur_radial \n"); | |||
EFblur.menuname = "Blur Radial"; | EFblur.menuname = "Blur Radial"; | |||
EFblur.menufunc = m_blur_radial; | EFblur.menufunc = m_blur_radial; | |||
EFblur.Farea = 2; // select area usable | EFblur.Farea = 2; // select area usable | |||
skipping to change at line 1729 | skipping to change at line 1732 | |||
zdialog_restore_inputs(zd); | zdialog_restore_inputs(zd); | |||
zdialog_run(zd,blur_radial_dialog_event,"save"); // run dialog | zdialog_run(zd,blur_radial_dialog_event,"save"); // run dialog | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int blur_radial_dialog_event(zdialog * zd, cchar *event) | int blur_radial_dialog_event(zdialog * zd, ch *event) | |||
{ | { | |||
using namespace blur_radial_names; | using namespace blur_radial_names; | |||
void blur_radial_mousefunc(); | void blur_radial_mousefunc(); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | |||
zdialog_fetch(zd,"RBrad",RBrad); | zdialog_fetch(zd,"RBrad",RBrad); | |||
skipping to change at line 1932 | skipping to change at line 1935 | |||
namespace blur_directed_names | namespace blur_directed_names | |||
{ | { | |||
float Dmdx, Dmdy, Dmdw, Dmdh; | float Dmdx, Dmdy, Dmdw, Dmdh; | |||
float DD, Dspan, Dintens; | float DD, Dspan, Dintens; | |||
editfunc EFblur; | editfunc EFblur; | |||
int Eww, Ehh; | int Eww, Ehh; | |||
} | } | |||
void m_blur_directed(GtkWidget *, cchar *menu) | void m_blur_directed(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace blur_directed_names; | using namespace blur_directed_names; | |||
int blur_directed_dialog_event(zdialog *zd, cchar *event); | int blur_directed_dialog_event(zdialog *zd, ch *event); | |||
void blur_directed_mousefunc(); | void blur_directed_mousefunc(); | |||
void * blur_directed_thread(void *); | void * blur_directed_thread(void *); | |||
F1_help_topic = "blur"; | F1_help_topic = "blur"; | |||
Plog(1,"m_blur_directed \n"); | Plog(1,"m_blur_directed \n"); | |||
EFblur.menuname = "Blur Directed"; | EFblur.menuname = "Blur Directed"; | |||
EFblur.menufunc = m_blur_directed; | EFblur.menufunc = m_blur_directed; | |||
EFblur.Farea = 2; // select area usable | EFblur.Farea = 2; // select area usable | |||
skipping to change at line 1988 | skipping to change at line 1991 | |||
zdialog_restore_inputs(zd); | zdialog_restore_inputs(zd); | |||
zdialog_run(zd,blur_directed_dialog_event,"save"); // run dialog | zdialog_run(zd,blur_directed_dialog_event,"save"); // run dialog | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int blur_directed_dialog_event(zdialog * zd, cchar *event) | int blur_directed_dialog_event(zdialog * zd, ch *event) | |||
{ | { | |||
using namespace blur_directed_names; | using namespace blur_directed_names; | |||
void blur_directed_mousefunc(); | void blur_directed_mousefunc(); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | |||
takeMouse(blur_directed_mousefunc,dragcursor); | takeMouse(blur_directed_mousefunc,dragcursor); | |||
skipping to change at line 2152 | skipping to change at line 2155 | |||
int pixseq_angle[1000]; | int pixseq_angle[1000]; | |||
int pixseq_dx[13000], pixseq_dy[13000]; | int pixseq_dx[13000], pixseq_dy[13000]; | |||
int pixseq_rad[13000]; | int pixseq_rad[13000]; | |||
int max1 = 999, max2 = 12999; // for later overflow check | int max1 = 999, max2 = 12999; // for later overflow check | |||
editfunc EFblur; | editfunc EFblur; | |||
VOL int Fcancel; | VOL int Fcancel; | |||
int Eww, Ehh; | int Eww, Ehh; | |||
} | } | |||
void m_blur_graduated(GtkWidget *, cchar *menu) | void m_blur_graduated(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace blur_graduated_names; | using namespace blur_graduated_names; | |||
int blur_graduated_dialog_event(zdialog *zd, cchar *event); | int blur_graduated_dialog_event(zdialog *zd, ch *event); | |||
void * blur_graduated_thread(void *); | void * blur_graduated_thread(void *); | |||
F1_help_topic = "blur"; | F1_help_topic = "blur"; | |||
Plog(1,"m_blur_graduated \n"); | Plog(1,"m_blur_graduated \n"); | |||
EFblur.menuname = "Blur Graduated"; | EFblur.menuname = "Blur Graduated"; | |||
EFblur.menufunc = m_blur_graduated; | EFblur.menufunc = m_blur_graduated; | |||
EFblur.Farea = 2; // select area usable | EFblur.Farea = 2; // select area usable | |||
EFblur.threadfunc = blur_graduated_thread; // thread function | EFblur.threadfunc = blur_graduated_thread; // thread function | |||
skipping to change at line 2208 | skipping to change at line 2211 | |||
zdialog_restore_inputs(zd); | zdialog_restore_inputs(zd); | |||
zdialog_run(zd,blur_graduated_dialog_event,"save"); // run dialog | zdialog_run(zd,blur_graduated_dialog_event,"save"); // run dialog | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int blur_graduated_dialog_event(zdialog * zd, cchar *event) | int blur_graduated_dialog_event(zdialog * zd, ch *event) | |||
{ | { | |||
using namespace blur_graduated_names; | using namespace blur_graduated_names; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | |||
zdialog_fetch(zd,"radius",radius); | zdialog_fetch(zd,"radius",radius); | |||
zdialog_fetch(zd,"con_limit",con_limit); | zdialog_fetch(zd,"con_limit",con_limit); | |||
skipping to change at line 2432 | skipping to change at line 2435 | |||
int pmode = 1; // 1/2 = blend/restore | int pmode = 1; // 1/2 = blend/restore | |||
int radius = 20; // mouse radius | int radius = 20; // mouse radius | |||
float powcent, powedge; // power at center and edge | float powcent, powedge; // power at center and edge | |||
float kernel[402][402]; // radius limit 200 | float kernel[402][402]; // radius limit 200 | |||
int mousex, mousey; // mouse click/drag position | int mousex, mousey; // mouse click/drag position | |||
editfunc EFblur; | editfunc EFblur; | |||
int Eww, Ehh; | int Eww, Ehh; | |||
} | } | |||
void m_blur_paint(GtkWidget *, cchar *menu) | void m_blur_paint(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace blur_paint_names; | using namespace blur_paint_names; | |||
int blur_paint_dialog_event(zdialog *zd, cchar *event); | int blur_paint_dialog_event(zdialog *zd, ch *event); | |||
void blur_paint_mousefunc(); | void blur_paint_mousefunc(); | |||
void * blur_paint_thread(void *); | void * blur_paint_thread(void *); | |||
F1_help_topic = "blur"; | F1_help_topic = "blur"; | |||
Plog(1,"m_blur_paint \n"); | Plog(1,"m_blur_paint \n"); | |||
EFblur.menuname = "Blur Paint"; | EFblur.menuname = "Blur Paint"; | |||
EFblur.menufunc = m_blur_paint; | EFblur.menufunc = m_blur_paint; | |||
EFblur.Farea = 2; // select area usable | EFblur.Farea = 2; // select area usable | |||
skipping to change at line 2493 | skipping to change at line 2496 | |||
zdialog_restore_inputs(zd); | zdialog_restore_inputs(zd); | |||
zdialog_run(zd,blur_paint_dialog_event,"save"); // run dialog | zdialog_run(zd,blur_paint_dialog_event,"save"); // run dialog | |||
zdialog_send_event(zd,"radius"); // get kernel initialized | zdialog_send_event(zd,"radius"); // get kernel initialized | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int blur_paint_dialog_event(zdialog * zd, cchar *event) | int blur_paint_dialog_event(zdialog * zd, ch *event) | |||
{ | { | |||
using namespace blur_paint_names; | using namespace blur_paint_names; | |||
void blur_paint_mousefunc(); | void blur_paint_mousefunc(); | |||
float frad, kern; | float frad, kern; | |||
int rad, dx, dy; | int rad, dx, dy; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | |||
skipping to change at line 2721 | skipping to change at line 2724 | |||
int conrad, incrad; // constant or increasing blur | int conrad, incrad; // constant or increasing blur | |||
int conbrad; // constant blur radius | int conbrad; // constant blur radius | |||
int minbrad; // min. blur radius | int minbrad; // min. blur radius | |||
int maxbrad; // max. blur radius | int maxbrad; // max. blur radius | |||
VOL int Fcancel; // GCC inconsistent | VOL int Fcancel; // GCC inconsistent | |||
int Eww, Ehh; // image dimensions | int Eww, Ehh; // image dimensions | |||
int maxdist; // max. area edge distance | int maxdist; // max. area edge distance | |||
editfunc EFblur; | editfunc EFblur; | |||
} | } | |||
void m_blur_background(GtkWidget *, const char *menu) | void m_blur_background(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace blur_background_names; | using namespace blur_background_names; | |||
int blur_background_dialog_event(zdialog* zd, const char *event); | int blur_background_dialog_event(zdialog* zd, ch *event); | |||
void * blur_background_thread(void *); | void * blur_background_thread(void *); | |||
Plog(1,"m_blur_background \n"); | Plog(1,"m_blur_background \n"); | |||
EFblur.menufunc = m_blur_background; | EFblur.menufunc = m_blur_background; | |||
EFblur.menuname = "Blur Background"; // function name | EFblur.menuname = "Blur Background"; // function name | |||
EFblur.Farea = 2; // select area usable (required) | EFblur.Farea = 2; // select area usable (required) | |||
EFblur.threadfunc = blur_background_thread; // thread function | EFblur.threadfunc = blur_background_thread; // thread function | |||
if (! edit_setup(EFblur)) return; // setup edit | if (! edit_setup(EFblur)) return; // setup edit | |||
skipping to change at line 2790 | skipping to change at line 2793 | |||
zdialog_resize(zd,300,0); | zdialog_resize(zd,300,0); | |||
zdialog_restore_inputs(zd); // restore previous inputs | zdialog_restore_inputs(zd); // restore previous inputs | |||
zdialog_run(zd,blur_background_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,blur_background_dialog_event,"save"); // run dialog - parallel | |||
if (sa_stat != 3) m_select_area(0,0); // start select area dialog | if (sa_stat != 3) m_select_area(0,0); // start select area dialog | |||
return; | return; | |||
} | } | |||
// dialog event and completion function | // dialog event and completion function | |||
int blur_background_dialog_event(zdialog *zd, const char *event) // blur_background dialog event function | int blur_background_dialog_event(zdialog *zd, ch *event) // blur_background dialog event function | |||
{ | { | |||
using namespace blur_background_names; | using namespace blur_background_names; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 2; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 2; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 3; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 3; // from f_open() | |||
if (zd->zstat) | if (zd->zstat) | |||
{ | { | |||
if (zd->zstat == 1) // [apply] | if (zd->zstat == 1) // [apply] | |||
skipping to change at line 2826 | skipping to change at line 2829 | |||
return 1; | return 1; | |||
} | } | |||
else if (zd->zstat == 2) { | else if (zd->zstat == 2) { | |||
if (zd_sela) zdialog_send_event(zd_sela,"done"); // kill select area dialog | if (zd_sela) zdialog_send_event(zd_sela,"done"); // kill select area dialog | |||
if (conrad) edit_addhist("rad:%d",conrad); | if (conrad) edit_addhist("rad:%d",conrad); | |||
if (incrad) edit_addhist("rad:%d-%d",minbrad,maxbrad); | if (incrad) edit_addhist("rad:%d-%d",minbrad,maxbrad); | |||
edit_done(0); | edit_done(0); | |||
} | } | |||
else { | else { | |||
Fcancel = 1; | // [cancel] or [x], discard edit | |||
// kill threads | Fescape = 1; | |||
edit_cancel(0); | // kill threads | |||
// [cancel] or [x], discard edit | edit_cancel(0); | |||
if (zd_sela) zdialog_send_event(zd_sela,"done"); | if (zd_sela) zdialog_send_event(zd_sela,"done"); | |||
} | } | |||
return 1; | return 1; | |||
} | } | |||
if (zstrstr("conrad incrad",event)) { | if (zstrstr("conrad incrad",event)) { | |||
zdialog_stuff(zd,"conrad",0); | zdialog_stuff(zd,"conrad",0); | |||
zdialog_stuff(zd,"incrad",0); | zdialog_stuff(zd,"incrad",0); | |||
zdialog_stuff(zd,event,1); | zdialog_stuff(zd,event,1); | |||
skipping to change at line 2869 | skipping to change at line 2872 | |||
if (incrad && sa_edgecalc_done) { // if increasing blur radius, | if (incrad && sa_edgecalc_done) { // if increasing blur radius, | |||
maxdist = 0; // get max. area edge distance | maxdist = 0; // get max. area edge distance | |||
for (ii = 0; ii < Eww * Ehh; ii++) { | for (ii = 0; ii < Eww * Ehh; ii++) { | |||
dist = sa_pixmap[ii]; | dist = sa_pixmap[ii]; | |||
if (dist > maxdist) maxdist = dist; | if (dist > maxdist) maxdist = dist; | |||
} | } | |||
} | } | |||
progress_reset(sa_Npixel); // initz. progress counter | progress_reset(sa_Npixel); // initz. progress counter | |||
Fwatchescape = 1; | ||||
// killable function | ||||
Fescape = 0; | ||||
do_wthreads(blur_background_wthread,NWT); // worker threads | do_wthreads(blur_background_wthread,NWT); // worker threads | |||
Fwatchescape = Fescape = 0; | ||||
progress_reset(0); | progress_reset(0); | |||
CEF->Fmods++; // image modified | CEF->Fmods++; // image modified | |||
CEF->Fsaved = 0; // not saved | CEF->Fsaved = 0; // not saved | |||
Fpaint2(); // update window | Fpaint2(); // update window | |||
return 0; | return 0; | |||
} | } | |||
// worker thread function | // worker thread function | |||
skipping to change at line 2896 | skipping to change at line 2902 | |||
int index = *((int *) (arg)); | int index = *((int *) (arg)); | |||
int ii, rad = 0, dist, npix; | int ii, rad = 0, dist, npix; | |||
int px, py, qx, qy; | int px, py, qx, qy; | |||
float *pix1, *pix3; | float *pix1, *pix3; | |||
float red, green, blue, F; | float red, green, blue, F; | |||
for (py = index; py < Ehh; py += NWT) // loop all image pixels | for (py = index; py < Ehh; py += NWT) // loop all image pixels | |||
for (px = 0; px < Eww; px++) | for (px = 0; px < Eww; px++) | |||
{ | { | |||
if (Fcancel) break; // cancel edit | if (Fescape) break; // cancel edit | |||
ii = py * Eww + px; | ii = py * Eww + px; | |||
dist = sa_pixmap[ii]; // area edge distance | dist = sa_pixmap[ii]; // area edge distance | |||
if (! dist) continue; // pixel outside the area | if (! dist) continue; // pixel outside the area | |||
if (conrad) rad = conbrad; // use constant blur radius | if (conrad) rad = conbrad; // use constant blur radius | |||
if (incrad) { // use increasing blur radius | if (incrad) { // use increasing blur radius | |||
if (! sa_edgecalc_done) return 0; // depending on edge distance | if (! sa_edgecalc_done) return 0; // depending on edge distance | |||
rad = minbrad + (maxbrad - minbrad) * dist / maxdist; | rad = minbrad + (maxbrad - minbrad) * dist / maxdist; | |||
skipping to change at line 2954 | skipping to change at line 2960 | |||
namespace blur_motion_names | namespace blur_motion_names | |||
{ | { | |||
editfunc EFblur; | editfunc EFblur; | |||
int Eww, Ehh; // image dimensions | int Eww, Ehh; // image dimensions | |||
int span; // blur span, pixels | int span; // blur span, pixels | |||
int angle; // blur angle, 0-180 deg. | int angle; // blur angle, 0-180 deg. | |||
PXM *tempxm; | PXM *tempxm; | |||
} | } | |||
void m_blur_motion(GtkWidget *, const char *menu) | void m_blur_motion(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace blur_motion_names; | using namespace blur_motion_names; | |||
void blur_motion_mousefunc(); | void blur_motion_mousefunc(); | |||
int blur_motion_dialog_event(zdialog* zd, const char *event); | int blur_motion_dialog_event(zdialog* zd, ch *event); | |||
void * blur_motion_thread(void *); | void * blur_motion_thread(void *); | |||
cchar *hintmess = "Drag mouse across image \n" | ch *hintmess = "Drag mouse across image \n" | |||
" to indicate blur direction"; | " to indicate blur direction"; | |||
Plog(1,"m_blur_motion \n"); | Plog(1,"m_blur_motion \n"); | |||
EFblur.menufunc = m_blur_motion; | EFblur.menufunc = m_blur_motion; | |||
EFblur.menuname = "Blur Motion"; | EFblur.menuname = "Blur Motion"; | |||
EFblur.Farea = 2; // select area usable | EFblur.Farea = 2; // select area usable | |||
EFblur.threadfunc = blur_motion_thread; // thread function | EFblur.threadfunc = blur_motion_thread; // thread function | |||
EFblur.mousefunc = blur_motion_mousefunc; // mouse function | EFblur.mousefunc = blur_motion_mousefunc; // mouse function | |||
skipping to change at line 3020 | skipping to change at line 3026 | |||
zdialog_run(zd,blur_motion_dialog_event); // run dialog - parallel | zdialog_run(zd,blur_motion_dialog_event); // run dialog - parallel | |||
if (sa_stat != 3) m_select_area(0,0); // start select area dialog 22.50 | if (sa_stat != 3) m_select_area(0,0); // start select area dialog 22.50 | |||
return; | return; | |||
} | } | |||
// dialog event and completion function | // dialog event and completion function | |||
int blur_motion_dialog_event(zdialog *zd, const char *event) | int blur_motion_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace blur_motion_names; | using namespace blur_motion_names; | |||
void blur_motion_mousefunc(); | void blur_motion_mousefunc(); | |||
void blur_motion_update(); | void blur_motion_update(); | |||
if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | |||
if (strmatch(event,"focus")) | if (strmatch(event,"focus")) | |||
skipping to change at line 3236 | skipping to change at line 3242 | |||
int Eww, Ehh; // image dimensions | int Eww, Ehh; // image dimensions | |||
int span; // blur span, pixels | int span; // blur span, pixels | |||
int angle; // blur angle, 0-180 deg. | int angle; // blur angle, 0-180 deg. | |||
int iter; // algorithm iterations | int iter; // algorithm iterations | |||
int supring; // suppress ringing | int supring; // suppress ringing | |||
PXM *E2pxm; | PXM *E2pxm; | |||
} | } | |||
// menu function | // menu function | |||
void m_fix_motionblur(GtkWidget *, const char *menu) | void m_fix_motionblur(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace fix_motionblur_names; | using namespace fix_motionblur_names; | |||
void fix_motionblur_mousefunc(); | void fix_motionblur_mousefunc(); | |||
int fix_motionblur_dialog_event(zdialog* zd, const char *event); | int fix_motionblur_dialog_event(zdialog* zd, ch *event); | |||
void * fix_motionblur_thread(void *); | void * fix_motionblur_thread(void *); | |||
cchar *hintmess = "Shift + drag mouse across image \n" | ch *hintmess = "Shift + drag mouse across image \n" | |||
" to indicate blur direction"; | " to indicate blur direction"; | |||
Plog(1,"m_fix_motionblur \n"); | Plog(1,"m_fix_motionblur \n"); | |||
EFfixmotionblur.menufunc = m_fix_motionblur; | EFfixmotionblur.menufunc = m_fix_motionblur; | |||
EFfixmotionblur.menuname = "Fix Motion Blur"; | EFfixmotionblur.menuname = "Fix Motion Blur"; | |||
EFfixmotionblur.Farea = 2; // select area usable | EFfixmotionblur.Farea = 2; // select area usable | |||
EFfixmotionblur.threadfunc = fix_motionblur_thread; // thread function | EFfixmotionblur.threadfunc = fix_motionblur_thread; // thread function | |||
EFfixmotionblur.mousefunc = fix_motionblur_mousefunc; // mouse function | EFfixmotionblur.mousefunc = fix_motionblur_mousefunc; // mouse function | |||
skipping to change at line 3305 | skipping to change at line 3311 | |||
zdialog_add_widget(zd,"zspin","supring","vb2","0|9|1|0"); | zdialog_add_widget(zd,"zspin","supring","vb2","0|9|1|0"); | |||
zdialog_restore_inputs(zd); | zdialog_restore_inputs(zd); | |||
zdialog_run(zd,fix_motionblur_dialog_event); // run dialog - parallel | zdialog_run(zd,fix_motionblur_dialog_event); // run dialog - parallel | |||
zdialog_send_event(zd,"init"); | zdialog_send_event(zd,"init"); | |||
return; | return; | |||
} | } | |||
// dialog event and completion function | // dialog event and completion function | |||
int fix_motionblur_dialog_event(zdialog *zd, const char *event) | int fix_motionblur_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace fix_motionblur_names; | using namespace fix_motionblur_names; | |||
void fix_motionblur_mousefunc(); | void fix_motionblur_mousefunc(); | |||
if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 3; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 4; // from f_open() | |||
if (zd->zstat) | if (zd->zstat) | |||
{ | { | |||
skipping to change at line 3675 | skipping to change at line 3681 | |||
{ | { | |||
enum dn_method { voodoo, chroma, anneal, flatten, median, SNN } | enum dn_method { voodoo, chroma, anneal, flatten, median, SNN } | |||
dn_method; | dn_method; | |||
int noise_histogram[3][256]; | int noise_histogram[3][256]; | |||
int dn_radius, dn_thresh; | int dn_radius, dn_thresh; | |||
float dn_darkareas; | float dn_darkareas; | |||
int Tradius, Tthresh; | int Tradius, Tthresh; | |||
zdialog *zd_denoise_measure; | zdialog *zd_denoise_measure; | |||
cchar *mformat = " mean RGB: %5.0f %5.0f %5.0f "; | ch *mformat = " mean RGB: %5.0f %5.0f %5.0f "; | |||
cchar *nformat = " mean noise: %5.2f %5.2f %5.2f "; | ch *nformat = " mean noise: %5.2f %5.2f %5.2f "; | |||
int Eww, Ehh; // image dimensions | int Eww, Ehh; // image dimensions | |||
editfunc EFdenoise; | editfunc EFdenoise; | |||
char edit_hist[200]; | ch edit_hist[200]; | |||
GtkWidget *denoise_measure_drawwin; | GtkWidget *denoise_measure_drawwin; | |||
} | } | |||
// menu function | // menu function | |||
void m_denoise(GtkWidget *, cchar *menu) // overhauled for paint edits | void m_denoise(GtkWidget *, ch *menu) // overhauled for paint edits | |||
{ | { | |||
using namespace denoise_names; | using namespace denoise_names; | |||
void denoise_characterize(); | void denoise_characterize(); | |||
int denoise_dialog_event(zdialog *zd, cchar *event); | int denoise_dialog_event(zdialog *zd, ch *event); | |||
void * denoise_thread(void *); | void * denoise_thread(void *); | |||
cchar *tip = "Apply repeatedly while watching the image."; | ch *tip = "Apply repeatedly while watching the image."; | |||
F1_help_topic = "denoise"; | F1_help_topic = "denoise"; | |||
Plog(1,"m_denoise \n"); | Plog(1,"m_denoise \n"); | |||
EFdenoise.menuname = "Denoise"; | EFdenoise.menuname = "Denoise"; | |||
EFdenoise.menufunc = m_denoise; | EFdenoise.menufunc = m_denoise; | |||
EFdenoise.Farea = 2; // select area usable | EFdenoise.Farea = 2; // select area usable | |||
EFdenoise.threadfunc = denoise_thread; // thread function | EFdenoise.threadfunc = denoise_thread; // thread function | |||
EFdenoise.Frestart = 1; // allow restart | EFdenoise.Frestart = 1; // allow restart | |||
skipping to change at line 3883 | skipping to change at line 3889 | |||
// zadd_locked(noise_histogram[rgb][diff],+1); // too slow | // zadd_locked(noise_histogram[rgb][diff],+1); // too slow | |||
++noise_histogram[rgb][diff]; // inaccurate | ++noise_histogram[rgb][diff]; // inaccurate | |||
} | } | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int denoise_dialog_event(zdialog * zd, cchar *event) // reworked for script files | int denoise_dialog_event(zdialog * zd, ch *event) // reworked for script files | |||
{ | { | |||
using namespace denoise_names; | using namespace denoise_names; | |||
void denoise_measure(); | void denoise_measure(); | |||
int ii; | int ii; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"apply")) zd->zstat = 2; // from script file | if (strmatch(event,"apply")) zd->zstat = 2; // from script file | |||
if (strmatch(event,"done")) zd->zstat = 4; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 4; // from edit_setup() or f_save() | |||
skipping to change at line 4017 | skipping to change at line 4023 | |||
Tradius = 2; | Tradius = 2; | |||
Tthresh = 0.7 * dn_thresh; | Tthresh = 0.7 * dn_thresh; | |||
get_edit_pixels_init(NWT,Tradius); | get_edit_pixels_init(NWT,Tradius); | |||
do_wthreads(denoise_anneal_wthread,NWT); // anneal 2x | do_wthreads(denoise_anneal_wthread,NWT); // anneal 2x | |||
PXM_copy(E3pxm,E1pxm); | PXM_copy(E3pxm,E1pxm); | |||
get_edit_pixels_init(NWT,Tradius); | get_edit_pixels_init(NWT,Tradius); | |||
do_wthreads(denoise_anneal_wthread,NWT); | do_wthreads(denoise_anneal_wthread,NWT); | |||
PXM_copy(E0pxm,E1pxm); // restore normal E1 | PXM_copy(E0pxm,E1pxm); // restore normal E1 | |||
snprintf(edit_hist,200,"voodoo thresh:%d",dn_thresh); // exif edit hist | snprintf(edit_hist,200,"voodoo thresh:%d",dn_thresh); // metadata edit hist | |||
} | } | |||
Tradius = dn_radius; // keep dialog parameters constant 22.31 | Tradius = dn_radius; // keep dialog parameters constant 22.31 | |||
Tthresh = dn_thresh; // during thread execution (bugfix) | Tthresh = dn_thresh; // during thread execution (bugfix) | |||
if (dn_method == chroma) | if (dn_method == chroma) | |||
{ | { | |||
if (sa_stat == 3) progress_reset(sa_Npixel); // initz. progress counter | if (sa_stat == 3) progress_reset(sa_Npixel); // initz. progress counter | |||
else progress_reset(Eww * Ehh); | else progress_reset(Eww * Ehh); | |||
skipping to change at line 4054 | skipping to change at line 4060 | |||
snprintf(edit_hist,200,"anneal rad:%d thresh:%d",Tradius,Tthresh); // edit params > edit hist | snprintf(edit_hist,200,"anneal rad:%d thresh:%d",Tradius,Tthresh); // edit params > edit hist | |||
} | } | |||
if (dn_method == flatten) | if (dn_method == flatten) | |||
{ | { | |||
if (sa_stat == 3) progress_reset(sa_Npixel); // initz. progress counter | if (sa_stat == 3) progress_reset(sa_Npixel); // initz. progress counter | |||
else progress_reset(Eww * Ehh); | else progress_reset(Eww * Ehh); | |||
get_edit_pixels_init(NWT,Tradius); // initz. pixel loop | get_edit_pixels_init(NWT,Tradius); // initz. pixel loop | |||
do_wthreads(denoise_flatten_wthread,NWT); // flatten denoise | do_wthreads(denoise_flatten_wthread,NWT); // flatten denoise | |||
snprintf(edit_hist,200,"flatten rad:%d thresh:%d",Tradius,Tthresh); // exif edit params > edit hist | snprintf(edit_hist,200,"flatten rad:%d thresh:%d",Tradius,Tthresh); // metadata edit params > edit hist | |||
} | } | |||
if (dn_method == median) | if (dn_method == median) | |||
{ | { | |||
if (sa_stat == 3) progress_reset(sa_Npixel); // initz. progress counter | if (sa_stat == 3) progress_reset(sa_Npixel); // initz. progress counter | |||
else progress_reset(Eww * Ehh); | else progress_reset(Eww * Ehh); | |||
get_edit_pixels_init(NWT,Tradius); // initz. pixel loop | get_edit_pixels_init(NWT,Tradius); // initz. pixel loop | |||
do_wthreads(denoise_median_wthread,NWT); // median denoise | do_wthreads(denoise_median_wthread,NWT); // median denoise | |||
snprintf(edit_hist,200,"median rad:%d thresh:%d",Tradius,Tthresh); // exif edit params > edit hist | snprintf(edit_hist,200,"median rad:%d thresh:%d",Tradius,Tthresh); // metadata edit params > edit hist | |||
} | } | |||
if (dn_method == SNN) // 22.18 | if (dn_method == SNN) // 22.18 | |||
{ | { | |||
if (sa_stat == 3) progress_reset(sa_Npixel); // initz. progress counter | if (sa_stat == 3) progress_reset(sa_Npixel); // initz. progress counter | |||
else progress_reset(Eww * Ehh); | else progress_reset(Eww * Ehh); | |||
get_edit_pixels_init(NWT,Tradius); // initz. pixel loop | get_edit_pixels_init(NWT,Tradius); // initz. pixel loop | |||
do_wthreads(denoise_SNN_wthread,NWT); // SNN denoise | do_wthreads(denoise_SNN_wthread,NWT); // SNN denoise | |||
snprintf(edit_hist,200,"SNN rad:%d",Tradius); // exif edit params > edit hist | snprintf(edit_hist,200,"SNN rad:%d",Tradius); // metadata edit params > edit hist | |||
} | } | |||
progress_reset(0); | progress_reset(0); | |||
if (dn_darkareas < 256) // revert brighter areas | if (dn_darkareas < 256) // revert brighter areas | |||
{ | { | |||
get_edit_pixels_init(1,Tradius); // initz. pixel loop | get_edit_pixels_init(1,Tradius); // initz. pixel loop | |||
while (true) | while (true) | |||
{ | { | |||
skipping to change at line 4352 | skipping to change at line 4358 | |||
} | } | |||
// Flatten: | // Flatten: | |||
// For each pixel, find two best-match opposing neighbors. | // For each pixel, find two best-match opposing neighbors. | |||
// Set pixel RGB values to mean of best neighbor RGB values. | // Set pixel RGB values to mean of best neighbor RGB values. | |||
void * denoise_flatten_wthread(void *arg) // 22.31 | void * denoise_flatten_wthread(void *arg) // 22.31 | |||
{ | { | |||
using namespace denoise_names; | using namespace denoise_names; | |||
int denoise_flatten_compfunc(cchar *rec1, cchar *rec2); | int denoise_flatten_compfunc(ch *rec1, ch *rec2); | |||
int index = *((int *) arg); | int index = *((int *) arg); | |||
int Fend, rad, rgb; | int Fend, rad, rgb; | |||
int px, py, px1, py1, px2, py2; | int px, py, px1, py1, px2, py2; | |||
float *pix1, *pix3; | float *pix1, *pix3; | |||
float *pixA, *pixB; | float *pixA, *pixB; | |||
float *pix91, *pix92, pix9[3]; | float *pix91, *pix92, pix9[3]; | |||
float blend, thresh; | float blend, thresh; | |||
int bmpx, bmpy; | int bmpx, bmpy; | |||
float diffA, diffB, diffAB, mindiff, mrgb; | float diffA, diffB, diffAB, mindiff, mrgb; | |||
skipping to change at line 4676 | skipping to change at line 4682 | |||
return 0; | return 0; | |||
} | } | |||
// dialog to measure noise at mouse position | // dialog to measure noise at mouse position | |||
void denoise_measure() | void denoise_measure() | |||
{ | { | |||
using namespace denoise_names; | using namespace denoise_names; | |||
int denoise_measure_dialog_event(zdialog *zd, cchar *event); | int denoise_measure_dialog_event(zdialog *zd, ch *event); | |||
GtkWidget *frdraw, *drawwin; | GtkWidget *frdraw, *drawwin; | |||
char text[100]; | ch text[100]; | |||
cchar *title = "Measure Noise"; | ch *title = "Measure Noise"; | |||
cchar *mousemess = "Move mouse in a monotone image area."; | ch *mousemess = "Move mouse in a monotone image area."; | |||
/*** | /*** | |||
_______________________________________ | _______________________________________ | |||
| Measure Noise | | | Measure Noise | | |||
| | | | | | |||
| Move mouse in a monotone image area. | | | Move mouse in a monotone image area. | | |||
| _____________________________________ | | | _____________________________________ | | |||
|| || | || || | |||
|| || | || || | |||
||.....................................|| | ||.....................................|| | |||
skipping to change at line 4740 | skipping to change at line 4746 | |||
snprintf(text,100,nformat,0.0,0.0,0.0); // mean noise: 0.00 0.00 0.00 | snprintf(text,100,nformat,0.0,0.0,0.0); // mean noise: 0.00 0.00 0.00 | |||
zdialog_add_widget(zd,"label","nlab","dialog",text); | zdialog_add_widget(zd,"label","nlab","dialog",text); | |||
zdialog_resize(zd,300,300); | zdialog_resize(zd,300,300); | |||
zdialog_run(zd,denoise_measure_dialog_event,"save"); // run dialog | zdialog_run(zd,denoise_measure_dialog_event,"save"); // run dialog | |||
return; | return; | |||
} | } | |||
// dialog event and completion function | // dialog event and completion function | |||
int denoise_measure_dialog_event(zdialog *zd, cchar *event) | int denoise_measure_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace denoise_names; | using namespace denoise_names; | |||
void denoise_measure_mousefunc(); | void denoise_measure_mousefunc(); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"focus")) | if (strmatch(event,"focus")) | |||
takeMouse(denoise_measure_mousefunc,dragcursor); // connect mouse function | takeMouse(denoise_measure_mousefunc,dragcursor); // connect mouse function | |||
skipping to change at line 4773 | skipping to change at line 4779 | |||
void denoise_measure_mousefunc() | void denoise_measure_mousefunc() | |||
{ | { | |||
using namespace denoise_names; | using namespace denoise_names; | |||
GtkWidget *drawwin; | GtkWidget *drawwin; | |||
GdkWindow *gdkwin; | GdkWindow *gdkwin; | |||
cairo_t *cr; | cairo_t *cr; | |||
zdialog *zd = zd_denoise_measure; | zdialog *zd = zd_denoise_measure; | |||
char text[100]; | ch text[100]; | |||
int mx, my, px, py, qx, qy, Npix; | int mx, my, px, py, qx, qy, Npix; | |||
float *pix3, R; | float *pix3, R; | |||
float Rm, Gm, Bm, Rn, Gn, Bn, Ro, Go, Bo; | float Rm, Gm, Bm, Rn, Gn, Bn, Ro, Go, Bo; | |||
int dww, dhh; | int dww, dhh; | |||
float max, xscale, yscale; | float max, xscale, yscale; | |||
float rx, ry; | float rx, ry; | |||
float Noise[400][3]; | float Noise[400][3]; | |||
double dashes[2] = { 1, 3 }; | double dashes[2] = { 1, 3 }; | |||
if (! E3pxm) return; | if (! E3pxm) return; | |||
if (! zd) return; | if (! zd) return; | |||
if (Fthreadbusy) return; // wait if denoise in progress | if (Ffuncbusy) return; // wait if denoise in progress | |||
mx = Mxposn; // mouse position | mx = Mxposn; // mouse position | |||
my = Myposn; | my = Myposn; | |||
if (mx < 13 || mx >= Eww-13) return; // must be 12+ pixels from image edge | if (mx < 13 || mx >= Eww-13) return; // must be 12+ pixels from image edge | |||
if (my < 13 || my >= Ehh-13) return; | if (my < 13 || my >= Ehh-13) return; | |||
draw_mousecircle(Mxposn,Myposn,10,0,0); // draw mouse circle, radius 10 | draw_mousecircle(Mxposn,Myposn,10,0,0); // draw mouse circle, radius 10 | |||
Npix = 0; | Npix = 0; | |||
skipping to change at line 4977 | skipping to change at line 4983 | |||
namespace defog_names | namespace defog_names | |||
{ | { | |||
editfunc EFdefog; | editfunc EFdefog; | |||
float blue; // blue attenuation, 0 ... 1 | float blue; // blue attenuation, 0 ... 1 | |||
float bright; // brightness addition, 0 ... 1 | float bright; // brightness addition, 0 ... 1 | |||
} | } | |||
// menu function | // menu function | |||
void m_defog(GtkWidget *, cchar *menu) // revised 22.40 | void m_defog(GtkWidget *, ch *menu) // revised 22.40 | |||
{ | { | |||
using namespace defog_names; | using namespace defog_names; | |||
int defog_dialog_event(zdialog* zd, cchar *event); | int defog_dialog_event(zdialog* zd, ch *event); | |||
void defog_curvedit(int spc); | void defog_curvedit(int spc); | |||
void * defog_thread(void *); | void * defog_thread(void *); | |||
GtkWidget *drawwin_scale; | GtkWidget *drawwin_scale; | |||
F1_help_topic = "defog"; | F1_help_topic = "defog"; | |||
Plog(1,"m_defog \n"); | Plog(1,"m_defog \n"); | |||
EFdefog.menuname = "defog"; | EFdefog.menuname = "defog"; | |||
skipping to change at line 5079 | skipping to change at line 5085 | |||
bright = 0; // no brightness addition | bright = 0; // no brightness addition | |||
zdialog_resize(zd,300,200); | zdialog_resize(zd,300,200); | |||
zdialog_run(zd,defog_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,defog_dialog_event,"save"); // run dialog - parallel | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int defog_dialog_event(zdialog *zd, cchar *event) | int defog_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace defog_names; | using namespace defog_names; | |||
spldat *sd = EFdefog.sd; | spldat *sd = EFdefog.sd; | |||
float Fapply = 0; | float Fapply = 0; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // cancel | if (strmatch(event,"escape")) zd->zstat = -2; // cancel | |||
if (strmatch(event,"done")) zd->zstat = 2; // apply and quit | if (strmatch(event,"done")) zd->zstat = 2; // apply and quit | |||
if (strmatch(event,"cancel")) zd->zstat = 3; // cancel | if (strmatch(event,"cancel")) zd->zstat = 3; // cancel | |||
if (strmatch(event,"apply")) Fapply = 2; // from script | if (strmatch(event,"apply")) Fapply = 2; // from script | |||
skipping to change at line 5274 | skipping to change at line 5280 | |||
return 0; | return 0; | |||
} | } | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// red eye removal function | // red eye removal function | |||
namespace redeye_names | namespace redeye_names | |||
{ | { | |||
struct sredmem { // red-eye struct in memory | struct sredmem { // red-eye struct in memory | |||
char type, space[3]; | ch type, space[3]; | |||
int cx, cy, ww, hh, rad, clicks; | int cx, cy, ww, hh, rad, clicks; | |||
float thresh, tstep; | float thresh, tstep; | |||
}; | }; | |||
sredmem redmem[100]; // store up to 100 red-eyes | sredmem redmem[100]; // store up to 100 red-eyes | |||
int Eww, Ehh; | int Eww, Ehh; | |||
int Nredmem = 0, maxredmem = 100; | int Nredmem = 0, maxredmem = 100; | |||
editfunc EFredeye; | editfunc EFredeye; | |||
#define PIXRED(pix) (25*pix[0]/(PIXBRIGHT(pix)+1)) // red brightness 0-100% | #define PIXRED(pix) (25*pix[0]/(PIXBRIGHT(pix)+1)) // red brightness 0-100% | |||
} | } | |||
// menu function | // menu function | |||
void m_redeyes(GtkWidget *, cchar *menu) | void m_redeyes(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace redeye_names; | using namespace redeye_names; | |||
int redeye_dialog_event(zdialog *zd, cchar *event); | int redeye_dialog_event(zdialog *zd, ch *event); | |||
void redeye_mousefunc(); | void redeye_mousefunc(); | |||
cchar *redeye_message = | ch *redeye_message = | |||
"Method 1:\n" | "Method 1:\n" | |||
" Left-click on red-eye to darken.\n" | " Left-click on red-eye to darken.\n" | |||
"Method 2:\n" | "Method 2:\n" | |||
" Drag down and right to enclose red-eye.\n" | " Drag down and right to enclose red-eye.\n" | |||
" Left-click on red-eye to darken.\n" | " Left-click on red-eye to darken.\n" | |||
"Undo red-eye:\n" | "Undo red-eye:\n" | |||
" Right-click on red-eye."; | " Right-click on red-eye."; | |||
F1_help_topic = "red eyes"; | F1_help_topic = "red eyes"; | |||
skipping to change at line 5332 | skipping to change at line 5338 | |||
zdialog_add_widget(zd,"label","lab1","dialog",redeye_message); | zdialog_add_widget(zd,"label","lab1","dialog",redeye_message); | |||
zdialog_run(zd,redeye_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,redeye_dialog_event,"save"); // run dialog - parallel | |||
Nredmem = 0; | Nredmem = 0; | |||
takeMouse(redeye_mousefunc,dragcursor); // connect mouse function | takeMouse(redeye_mousefunc,dragcursor); // connect mouse function | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int redeye_dialog_event(zdialog *zd, cchar *event) | int redeye_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace redeye_names; | using namespace redeye_names; | |||
void redeye_mousefunc(); | void redeye_mousefunc(); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 2; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 2; // from f_open() | |||
if (zd->zstat) | if (zd->zstat) | |||
skipping to change at line 5553 | skipping to change at line 5559 | |||
} | } | |||
// darken a red-eye and increase click count | // darken a red-eye and increase click count | |||
void redeye_darken(int ii) | void redeye_darken(int ii) | |||
{ | { | |||
using namespace redeye_names; | using namespace redeye_names; | |||
int cx, cy, ww, hh, px, py, rad, clicks; | int cx, cy, ww, hh, px, py, rad, clicks; | |||
float rd, thresh, tstep; | float rd, thresh, tstep; | |||
char type; | ch type; | |||
float *ppix; | float *ppix; | |||
type = redmem[ii].type; | type = redmem[ii].type; | |||
cx = redmem[ii].cx; | cx = redmem[ii].cx; | |||
cy = redmem[ii].cy; | cy = redmem[ii].cy; | |||
ww = redmem[ii].ww; | ww = redmem[ii].ww; | |||
hh = redmem[ii].hh; | hh = redmem[ii].hh; | |||
rad = redmem[ii].rad; | rad = redmem[ii].rad; | |||
thresh = redmem[ii].thresh; | thresh = redmem[ii].thresh; | |||
tstep = redmem[ii].tstep; | tstep = redmem[ii].tstep; | |||
skipping to change at line 5606 | skipping to change at line 5612 | |||
// Build a distribution of redness for a red-eye. Use this information | // Build a distribution of redness for a red-eye. Use this information | |||
// to set initial threshold and step size for stepwise darkening. | // to set initial threshold and step size for stepwise darkening. | |||
void redeye_distr(int ii) | void redeye_distr(int ii) | |||
{ | { | |||
using namespace redeye_names; | using namespace redeye_names; | |||
int cx, cy, ww, hh, rad, px, py; | int cx, cy, ww, hh, rad, px, py; | |||
int bin, npix, dbins[20], bsum, blim; | int bin, npix, dbins[20], bsum, blim; | |||
float rd, maxred, minred, redpart, dbase, dstep; | float rd, maxred, minred, redpart, dbase, dstep; | |||
char type; | ch type; | |||
float *ppix; | float *ppix; | |||
type = redmem[ii].type; | type = redmem[ii].type; | |||
cx = redmem[ii].cx; | cx = redmem[ii].cx; | |||
cy = redmem[ii].cy; | cy = redmem[ii].cy; | |||
ww = redmem[ii].ww; | ww = redmem[ii].ww; | |||
hh = redmem[ii].hh; | hh = redmem[ii].hh; | |||
rad = redmem[ii].rad; | rad = redmem[ii].rad; | |||
maxred = 0; | maxred = 0; | |||
skipping to change at line 5749 | skipping to change at line 5755 | |||
// with a reflection of pixels outside the area. | // with a reflection of pixels outside the area. | |||
namespace smarterase_names | namespace smarterase_names | |||
{ | { | |||
editfunc EFsmarterase; | editfunc EFsmarterase; | |||
int Eww, Ehh; | int Eww, Ehh; | |||
} | } | |||
// menu function | // menu function | |||
void m_smart_erase(GtkWidget *, const char *menu) | void m_smart_erase(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace smarterase_names; | using namespace smarterase_names; | |||
int smart_erase_dialog_event(zdialog* zd, const char *event); | int smart_erase_dialog_event(zdialog* zd, ch *event); | |||
cchar *erase_message = "Drag mouse to select. Erase. Repeat. \n" | ch *erase_message = "Drag mouse to select. Erase. Repeat. \n" | |||
"Click: extend selection to mouse."; | "Click: extend selection to mouse."; | |||
F1_help_topic = "smart erase"; | F1_help_topic = "smart erase"; | |||
Plog(1,"m_smart_erase \n"); | Plog(1,"m_smart_erase \n"); | |||
EFsmarterase.menufunc = m_smart_erase; | EFsmarterase.menufunc = m_smart_erase; | |||
EFsmarterase.menuname = "Smart Erase"; | EFsmarterase.menuname = "Smart Erase"; | |||
EFsmarterase.Farea = 0; // select area deleted | EFsmarterase.Farea = 0; // select area deleted | |||
EFsmarterase.mousefunc = sa_mouse_select; // mouse function (use select area) | EFsmarterase.mousefunc = sa_mouse_select; // mouse function (use select area) | |||
if (! edit_setup(EFsmarterase)) return; // setup edit | if (! edit_setup(EFsmarterase)) return; // setup edit | |||
skipping to change at line 5818 | skipping to change at line 5824 | |||
sa_lastx = sa_lasty = 0; // initz. for sa_mouse_select | sa_lastx = sa_lasty = 0; // initz. for sa_mouse_select | |||
takeMouse(sa_mouse_select,0); // use select area mouse function | takeMouse(sa_mouse_select,0); // use select area mouse function | |||
sa_show(1,0); | sa_show(1,0); | |||
zdialog_run(zd,smart_erase_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,smart_erase_dialog_event,"save"); // run dialog - parallel | |||
return; | return; | |||
} | } | |||
// dialog event and completion function | // dialog event and completion function | |||
int smart_erase_dialog_event(zdialog *zd, const char *event) | int smart_erase_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace smarterase_names; | using namespace smarterase_names; | |||
void smart_erase_func(int mode); | void smart_erase_func(int mode); | |||
int smart_erase_blur(float radius); | int smart_erase_blur(float radius); | |||
float radius; | float radius; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | |||
skipping to change at line 5891 | skipping to change at line 5897 | |||
void smart_erase_func(int mode) | void smart_erase_func(int mode) | |||
{ | { | |||
using namespace smarterase_names; | using namespace smarterase_names; | |||
int px, py, npx, npy; | int px, py, npx, npy; | |||
int qx, qy, sx, sy, tx, ty; | int qx, qy, sx, sy, tx, ty; | |||
int ww, hh, ii, rad, inc, cc; | int ww, hh, ii, rad, inc, cc; | |||
int dist2, mindist2; | int dist2, mindist2; | |||
float slope; | float slope; | |||
char *pmap; | ch *pmap; | |||
float *pix1, *pix3; | float *pix1, *pix3; | |||
int nc = E1pxm->nc, pcc = nc * sizeof(float); | int nc = E1pxm->nc, pcc = nc * sizeof(float); | |||
if (sa_stat != 3) return; // nothing selected | if (sa_stat != 3) return; // nothing selected | |||
if (! sa_validate()) return; // area invalid for curr. image file | if (! sa_validate()) return; // area invalid for curr. image file | |||
ww = E1pxm->ww; | ww = E1pxm->ww; | |||
hh = E1pxm->hh; | hh = E1pxm->hh; | |||
for (py = sa_miny; py < sa_maxy; py++) // undo all pixels in area | for (py = sa_miny; py < sa_maxy; py++) // undo all pixels in area | |||
skipping to change at line 5917 | skipping to change at line 5923 | |||
pix1 = PXMpix(E1pxm,px,py); // input pixel | pix1 = PXMpix(E1pxm,px,py); // input pixel | |||
pix3 = PXMpix(E3pxm,px,py); // output pixel | pix3 = PXMpix(E3pxm,px,py); // output pixel | |||
memcpy(pix3,pix1,pcc); | memcpy(pix3,pix1,pcc); | |||
} | } | |||
Fpaint2(); // update window | Fpaint2(); // update window | |||
if (mode == 2) return; // mode = undo, done | if (mode == 2) return; // mode = undo, done | |||
cc = ww * hh; // allocate pixel done map | cc = ww * hh; // allocate pixel done map | |||
pmap = (char *) zmalloc(cc,"smart erase"); | pmap = (ch *) zmalloc(cc,"smart erase"); | |||
for (py = sa_miny; py < sa_maxy; py++) // loop all pixels in area | for (py = sa_miny; py < sa_maxy; py++) // loop all pixels in area | |||
for (px = sa_minx; px < sa_maxx; px++) | for (px = sa_minx; px < sa_maxx; px++) | |||
{ | { | |||
ii = py * ww + px; | ii = py * ww + px; | |||
if (! sa_pixmap[ii]) continue; // pixel not selected | if (! sa_pixmap[ii]) continue; // pixel not selected | |||
if (pmap[ii]) continue; // pixel already done | if (pmap[ii]) continue; // pixel already done | |||
mindist2 = 999999; // find nearest edge | mindist2 = 999999; // find nearest edge | |||
npx = npy = 0; | npx = npy = 0; | |||
skipping to change at line 6121 | skipping to change at line 6127 | |||
int mode = 1; // 1/2 = reduce halo / undo | int mode = 1; // 1/2 = reduce halo / undo | |||
float Mrad; // mouse radius | float Mrad; // mouse radius | |||
float Power; // power at center, edge | float Power; // power at center, edge | |||
int E3ww, E3hh; | int E3ww, E3hh; | |||
editfunc EFremovehalo; | editfunc EFremovehalo; | |||
} | } | |||
// menu function | // menu function | |||
void m_remove_halo(GtkWidget *, cchar *menu) // 22.14 | void m_remove_halo(GtkWidget *, ch *menu) // 22.14 | |||
{ | { | |||
using namespace remove_halo_names; | using namespace remove_halo_names; | |||
int remove_halo_dialog_event(zdialog* zd, cchar *event); | int remove_halo_dialog_event(zdialog* zd, ch *event); | |||
void remove_halo_mousefunc(); | void remove_halo_mousefunc(); | |||
cchar *mess1 = " left drag: reduce halo right drag: undo "; | ch *mess1 = " left drag: reduce halo right drag: undo "; | |||
F1_help_topic = "remove halo"; | F1_help_topic = "remove halo"; | |||
Plog(1,"m_remove_halo \n"); | Plog(1,"m_remove_halo \n"); | |||
EFremovehalo.menufunc = m_remove_halo; | EFremovehalo.menufunc = m_remove_halo; | |||
EFremovehalo.menuname = "Remove Halo"; | EFremovehalo.menuname = "Remove Halo"; | |||
EFremovehalo.Farea = 1; // select area ignored | EFremovehalo.Farea = 1; // select area ignored | |||
EFremovehalo.mousefunc = remove_halo_mousefunc; // mouse function | EFremovehalo.mousefunc = remove_halo_mousefunc; // mouse function | |||
if (! edit_setup(EFremovehalo)) return; // setup edit | if (! edit_setup(EFremovehalo)) return; // setup edit | |||
skipping to change at line 6178 | skipping to change at line 6184 | |||
zdialog_send_event(zd,"Mrad"); // initialize mouse params | zdialog_send_event(zd,"Mrad"); // initialize mouse params | |||
mode = 1; // start with paint mode | mode = 1; // start with paint mode | |||
takeMouse(remove_halo_mousefunc,drawcursor); // connect mouse function | takeMouse(remove_halo_mousefunc,drawcursor); // connect mouse function | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int remove_halo_dialog_event(zdialog *zd, cchar *event) | int remove_halo_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace remove_halo_names; | using namespace remove_halo_names; | |||
void remove_halo_mousefunc(); | void remove_halo_mousefunc(); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 2; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 2; // from f_open() | |||
if (zd->zstat) | if (zd->zstat) | |||
skipping to change at line 6369 | skipping to change at line 6375 | |||
namespace adjust_RGB_names | namespace adjust_RGB_names | |||
{ | { | |||
editfunc EF_RGB; // edit function data | editfunc EF_RGB; // edit function data | |||
float inputs[8]; | float inputs[8]; | |||
int Eww, Ehh; | int Eww, Ehh; | |||
} | } | |||
// menu function | // menu function | |||
void m_adjust_RGB(GtkWidget *, cchar *menu) | void m_adjust_RGB(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace adjust_RGB_names; | using namespace adjust_RGB_names; | |||
int RGB_dialog_event(zdialog *zd, cchar *event); | int RGB_dialog_event(zdialog *zd, ch *event); | |||
void * RGB_thread(void *); | void * RGB_thread(void *); | |||
F1_help_topic = "adjust RGB"; | F1_help_topic = "adjust RGB"; | |||
Plog(1,"m_adjust_RGB \n"); | Plog(1,"m_adjust_RGB \n"); | |||
EF_RGB.menuname = "Adjust RGB"; | EF_RGB.menuname = "Adjust RGB"; | |||
EF_RGB.menufunc = m_adjust_RGB; | EF_RGB.menufunc = m_adjust_RGB; | |||
EF_RGB.FprevReq = 1; // use preview | EF_RGB.FprevReq = 1; // use preview | |||
EF_RGB.Farea = 2; // select area usable | EF_RGB.Farea = 2; // select area usable | |||
skipping to change at line 6446 | skipping to change at line 6452 | |||
zdialog_resize(zd,300,0); | zdialog_resize(zd,300,0); | |||
zdialog_restore_inputs(zd); // restore prior inputs | zdialog_restore_inputs(zd); // restore prior inputs | |||
zdialog_run(zd,RGB_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,RGB_dialog_event,"save"); // run dialog - parallel | |||
zdialog_send_event(zd,"apply"); | zdialog_send_event(zd,"apply"); | |||
return; | return; | |||
} | } | |||
// RGB dialog event and completion function | // RGB dialog event and completion function | |||
int RGB_dialog_event(zdialog *zd, cchar *event) // RGB dialog event function | int RGB_dialog_event(zdialog *zd, ch *event) // RGB dialog event function | |||
{ | { | |||
using namespace adjust_RGB_names; | using namespace adjust_RGB_names; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 2; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 2; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 3; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 3; // from f_open() | |||
if (strmatch(event,"fullsize")) { // from select area | if (strmatch(event,"fullsize")) { // from select area | |||
edit_fullsize(); | edit_fullsize(); | |||
Eww = E3pxm->ww; | Eww = E3pxm->ww; | |||
skipping to change at line 6670 | skipping to change at line 6676 | |||
float Rm, Gm, Bm; // RGB image color to match | float Rm, Gm, Bm; // RGB image color to match | |||
float Hm, Sm, Lm; // corresp. HSL color | float Hm, Sm, Lm; // corresp. HSL color | |||
float Mlev; // match level 0..1 = 100% | float Mlev; // match level 0..1 = 100% | |||
float Hc, Sc, Lc; // new color to add | float Hc, Sc, Lc; // new color to add | |||
float Rc, Gc, Bc; // corresp. RGB color | float Rc, Gc, Bc; // corresp. RGB color | |||
float Adj; // color adjustment, 0..1 = 100% | float Adj; // color adjustment, 0..1 = 100% | |||
} | } | |||
// menu function | // menu function | |||
void m_adjust_HSL(GtkWidget *, cchar *menu) | void m_adjust_HSL(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace adjust_HSL_names; | using namespace adjust_HSL_names; | |||
void HSL_RGBcolor(GtkWidget *drawarea, cairo_t *cr, int *); | void HSL_RGBcolor(GtkWidget *drawarea, cairo_t *cr, int *); | |||
void HSL_Hscale(GtkWidget *drawarea, cairo_t *cr, int *); | void HSL_Hscale(GtkWidget *drawarea, cairo_t *cr, int *); | |||
int HSL_dialog_event(zdialog *zd, cchar *event); | int HSL_dialog_event(zdialog *zd, ch *event); | |||
void HSL_mousefunc(); | void HSL_mousefunc(); | |||
void * HSL_thread(void *); | void * HSL_thread(void *); | |||
F1_help_topic = "adjust HSL"; | F1_help_topic = "adjust HSL"; | |||
Plog(1,"m_adjust_HSL \n"); | Plog(1,"m_adjust_HSL \n"); | |||
EF_HSL.menuname = "Adjust HSL"; | EF_HSL.menuname = "Adjust HSL"; | |||
EF_HSL.menufunc = m_adjust_HSL; | EF_HSL.menufunc = m_adjust_HSL; | |||
EF_HSL.FprevReq = 1; // use preview | EF_HSL.FprevReq = 1; // use preview | |||
skipping to change at line 6843 | skipping to change at line 6849 | |||
cairo_move_to(cr,px,0); | cairo_move_to(cr,px,0); | |||
cairo_line_to(cr,px,hh-1); | cairo_line_to(cr,px,hh-1); | |||
cairo_stroke(cr); | cairo_stroke(cr); | |||
} | } | |||
return; | return; | |||
} | } | |||
// HSL dialog event and completion function | // HSL dialog event and completion function | |||
int HSL_dialog_event(zdialog *zd, cchar *event) // HSL dialog event function | int HSL_dialog_event(zdialog *zd, ch *event) // HSL dialog event function | |||
{ | { | |||
using namespace adjust_HSL_names; | using namespace adjust_HSL_names; | |||
void HSL_mousefunc(); | void HSL_mousefunc(); | |||
int mod = 0; | int mod = 0; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 2; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 2; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 3; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 3; // from f_open() | |||
skipping to change at line 6972 | skipping to change at line 6978 | |||
} | } | |||
// mouse function | // mouse function | |||
// click on image to set the color to match and change | // click on image to set the color to match and change | |||
void HSL_mousefunc() | void HSL_mousefunc() | |||
{ | { | |||
using namespace adjust_HSL_names; | using namespace adjust_HSL_names; | |||
int mx, my, px, py; | int mx, my, px, py; | |||
char color[20]; | ch color[20]; | |||
float *pix1, R, G, B; | float *pix1, R, G, B; | |||
float f256 = 1.0 / 256.0; | float f256 = 1.0 / 256.0; | |||
zdialog *zd = EF_HSL.zd; | zdialog *zd = EF_HSL.zd; | |||
if (! KBshiftkey) return; // check shift + left or right click | if (! KBshiftkey) return; // check shift + left or right click | |||
if (! LMclick && ! RMclick) return; | if (! LMclick && ! RMclick) return; | |||
mx = Mxclick; // clicked pixel on image | mx = Mxclick; // clicked pixel on image | |||
my = Myclick; | my = Myclick; | |||
skipping to change at line 7271 | skipping to change at line 7277 | |||
if (H < 0) H += 360; | if (H < 0) H += 360; | |||
return; | return; | |||
} | } | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// convert color profile of current image | // convert color profile of current image | |||
editfunc EFcolorprof; | editfunc EFcolorprof; | |||
char ICCprofilename[100]; | ch ICCprofilename[100]; | |||
// new color profile name | // new color profile name | |||
char colorprof1[200] = "/usr/share/color/icc/colord/AdobeRGB1998.icc"; | ch colorprof1[200] = "/usr/share/color/icc/colord/AdobeRGB1998.icc"; | |||
char colorprof2[200] = "/usr/share/color/icc/colord/sRGB.icc"; | ch colorprof2[200] = "/usr/share/color/icc/colord/sRGB.icc"; | |||
// menu function | // menu function | |||
void m_color_profile(GtkWidget *, cchar *menu) | void m_color_profile(GtkWidget *, ch *menu) | |||
{ | { | |||
int colorprof_dialog_event(zdialog *zd, cchar *event); | int colorprof_dialog_event(zdialog *zd, ch *event); | |||
zdialog *zd; | zdialog *zd; | |||
int err; | int err; | |||
cchar *exifkey[2], *exifdata[2]; | ch *metakey[2]; | |||
ch *metadatadata[2]; | ||||
F1_help_topic = "color profile"; | F1_help_topic = "color profile"; | |||
Plog(1,"m_color_profile \n"); | Plog(1,"m_color_profile \n"); | |||
m_viewmode(0,"F"); // file view mode | m_viewmode(0,"F"); // file view mode | |||
EFcolorprof.menuname = "Color Profile"; | EFcolorprof.menuname = "Color Profile"; | |||
EFcolorprof.menufunc = m_color_profile; | EFcolorprof.menufunc = m_color_profile; | |||
EFcolorprof.Frestart = 1; // allow restart | EFcolorprof.Frestart = 1; // allow restart | |||
skipping to change at line 7335 | skipping to change at line 7342 | |||
zdialog_run(zd,colorprof_dialog_event,"save"); // run dialog, parallel | zdialog_run(zd,colorprof_dialog_event,"save"); // run dialog, parallel | |||
zdialog_wait(zd); // wait for completion | zdialog_wait(zd); // wait for completion | |||
if (! *ICCprofilename) return; // no color profile change | if (! *ICCprofilename) return; // no color profile change | |||
m_file_save_version(0,0); // save as new version and re-open | m_file_save_version(0,0); // save as new version and re-open | |||
zshell(0,"rm -f %s/undo_*",temp_folder); // remove undo/redo files | zshell(0,"rm -f %s/undo_*",temp_folder); // remove undo/redo files | |||
URS_pos = URS_max = 0; // reset undo/redo stack | URS_pos = URS_max = 0; // reset undo/redo stack | |||
exifkey[0] = exif_colorprof2_key; | metakey[0] = meta_colorprof2_key; | |||
// remove embedded color profile | // remove embedded color profile | |||
exifdata[0] = ""; | metadatadata[0] = 0; | |||
exifkey[1] = exif_colorprof1_key; | metakey[1] = meta_colorprof1_key; | |||
// set new color profile name | // set new color profile name | |||
exifdata[1] = ICCprofilename; | metadatadata[1] = ICCprofilename; | |||
err = exif_put(curr_file,exifkey,exifdata,2); | err = meta_put(curr_file,(ch **) metakey,metadatadata,2); | |||
if (err) zmessageACK(Mwin,"Unable to change EXIF color profile"); | if (err) zmessageACK(Mwin,"Unable to change metadata color profile"); | |||
zmessageACK(Mwin,"automatic new version created"); | zmessageACK(Mwin,"automatic new version created"); | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int colorprof_dialog_event(zdialog *zd, cchar *event) | int colorprof_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
cchar *title = "color profile"; | ch *title = "color profile"; | |||
char *file; | ch *file; | |||
float *fpix1, *fpix2; | float *fpix1, *fpix2; | |||
float f256 = 1.0 / 256.0; | float f256 = 1.0 / 256.0; | |||
uint Npix, nn; | uint Npix, nn; | |||
cmsHTRANSFORM cmsxform; | cmsHTRANSFORM cmsxform; | |||
cmsHPROFILE cmsprof1, cmsprof2; | cmsHPROFILE cmsprof1, cmsprof2; | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"apply")) zd->zstat = 1; // from script | if (strmatch(event,"apply")) zd->zstat = 1; // from script | |||
if (strmatch(event,"done")) zd->zstat = 2; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 2; // from edit_setup() or f_save() | |||
skipping to change at line 7504 | skipping to change at line 7511 | |||
typedef struct { | typedef struct { | |||
uint16 px1, py1, px2, py2; // pixel group extreme pixels | uint16 px1, py1, px2, py2; // pixel group extreme pixels | |||
int span2; // span from px1/py1 to px2/py2 | int span2; // span from px1/py1 to px2/py2 | |||
} sgroupspan; | } sgroupspan; | |||
sgroupspan groupspan[maxgroups]; | sgroupspan groupspan[maxgroups]; | |||
} | } | |||
// menu function | // menu function | |||
void m_remove_dust(GtkWidget *, const char *menu) | void m_remove_dust(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace dust_names; | using namespace dust_names; | |||
int dust_dialog_event(zdialog *zd, cchar *event); | int dust_dialog_event(zdialog *zd, ch *event); | |||
void * dust_thread(void *); | void * dust_thread(void *); | |||
F1_help_topic = "remove dust"; | F1_help_topic = "remove dust"; | |||
Plog(1,"m_remove_dust \n"); | Plog(1,"m_remove_dust \n"); | |||
m_viewmode(0,"F"); // file view mode | m_viewmode(0,"F"); // file view mode | |||
EFdust.menufunc = m_remove_dust; | EFdust.menufunc = m_remove_dust; | |||
EFdust.menuname = "Remove Dust"; | EFdust.menuname = "Remove Dust"; | |||
skipping to change at line 7585 | skipping to change at line 7592 | |||
contrast = 0.001 * contrast; // scale 0 to 1 = black/white | contrast = 0.001 * contrast; // scale 0 to 1 = black/white | |||
zdialog_run(zd,dust_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,dust_dialog_event,"save"); // run dialog - parallel | |||
thread_signal(); | thread_signal(); | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int dust_dialog_event(zdialog *zd, cchar *event) | int dust_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace dust_names; | using namespace dust_names; | |||
void dust_erase(); | void dust_erase(); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 2; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 2; // from f_open() | |||
if (zd->zstat) | if (zd->zstat) | |||
skipping to change at line 7965 | skipping to change at line 7972 | |||
void dust_erase() | void dust_erase() | |||
{ | { | |||
using namespace dust_names; | using namespace dust_names; | |||
int cc, ii, px, py, inc; | int cc, ii, px, py, inc; | |||
int qx, qy, npx, npy; | int qx, qy, npx, npy; | |||
int sx, sy, tx, ty; | int sx, sy, tx, ty; | |||
int rad, dist, dist2, mindist2; | int rad, dist, dist2, mindist2; | |||
float slope, f1, f2; | float slope, f1, f2; | |||
float *pix1, *pix3; | float *pix1, *pix3; | |||
char *pmap; | ch *pmap; | |||
int nc = E1pxm->nc, pcc = nc * sizeof(float); | int nc = E1pxm->nc, pcc = nc * sizeof(float); | |||
zadd_locked(Ffuncbusy,+1); | zadd_locked(Ffuncbusy,+1); | |||
PXM_free(E3pxm); // not a thread | PXM_free(E3pxm); // not a thread | |||
E3pxm = PXM_copy(E9pxm); | E3pxm = PXM_copy(E9pxm); | |||
cc = E1pxm->ww * E1pxm->hh; // allocate pixel done map | cc = E1pxm->ww * E1pxm->hh; // allocate pixel done map | |||
pmap = (char *) zmalloc(cc,"remove dust"); | pmap = (ch *) zmalloc(cc,"remove dust"); | |||
for (py = 0; py < E1pxm->hh; py++) // loop all pixels | for (py = 0; py < E1pxm->hh; py++) // loop all pixels | |||
for (px = 0; px < E1pxm->ww; px++) | for (px = 0; px < E1pxm->ww; px++) | |||
{ | { | |||
ii = py * E1pxm->ww + px; | ii = py * E1pxm->ww + px; | |||
if (! pixgroup[ii]) continue; // not a dust pixel | if (! pixgroup[ii]) continue; // not a dust pixel | |||
if (pmap[ii]) continue; // skip pixels already done | if (pmap[ii]) continue; // skip pixels already done | |||
mindist2 = 999999; | mindist2 = 999999; | |||
npx = npy = 0; | npx = npy = 0; | |||
skipping to change at line 8105 | skipping to change at line 8112 | |||
namespace chromatic1_names | namespace chromatic1_names | |||
{ | { | |||
editfunc EFchromatic1; | editfunc EFchromatic1; | |||
double Rf1, Rf2, Rf3, Bf1, Bf2, Bf3; | double Rf1, Rf2, Rf3, Bf1, Bf2, Bf3; | |||
int Eww, Ehh; | int Eww, Ehh; | |||
int cx, cy; | int cx, cy; | |||
uint8 *pixcon; | uint8 *pixcon; | |||
int threshcon; | int threshcon; | |||
int evrgb; | int evrgb; | |||
float evF1, evF2, evF3; | float evF1, evF2, evF3; | |||
double evRsum1[max_threads]; | double evRsum1[NWT]; | |||
double evRsum2; | double evRsum2; | |||
} | } | |||
// menu function | // menu function | |||
void m_chromatic1(GtkWidget *, cchar *menu) | void m_chromatic1(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace chromatic1_names; | using namespace chromatic1_names; | |||
void chromatic1_threshcon(); | void chromatic1_threshcon(); | |||
int chromatic1_dialog_event(zdialog* zd, cchar *event); | int chromatic1_dialog_event(zdialog* zd, ch *event); | |||
cchar *title = "Chromatic Aberration"; | ch *title = "Chromatic Aberration"; | |||
F1_help_topic = "chromatic 1"; | F1_help_topic = "chromatic 1"; | |||
Plog(1,"m_chromatic1 \n"); | Plog(1,"m_chromatic1 \n"); | |||
EFchromatic1.menuname = "Chromatic 1"; // setup edit | EFchromatic1.menuname = "Chromatic 1"; // setup edit | |||
EFchromatic1.menufunc = m_chromatic1; | EFchromatic1.menufunc = m_chromatic1; | |||
EFchromatic1.Farea = 1; // select area ignored | EFchromatic1.Farea = 1; // select area ignored | |||
if (! edit_setup(EFchromatic1)) return; | if (! edit_setup(EFchromatic1)) return; | |||
skipping to change at line 8177 | skipping to change at line 8184 | |||
zdialog_add_widget(zd,"hbox","hbopt","dialog",0,"space=5"); | zdialog_add_widget(zd,"hbox","hbopt","dialog",0,"space=5"); | |||
zdialog_add_widget(zd,"label","labopt","hbopt","Find optimum factors:"); | zdialog_add_widget(zd,"label","labopt","hbopt","Find optimum factors:"); | |||
zdialog_add_widget(zd,"button","search","hbopt","Search","space=5"); | zdialog_add_widget(zd,"button","search","hbopt","Search","space=5"); | |||
zdialog_run(zd,chromatic1_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,chromatic1_dialog_event,"save"); // run dialog - parallel | |||
return; | return; | |||
} | } | |||
// dialog event and completion function | // dialog event and completion function | |||
int chromatic1_dialog_event(zdialog *zd, cchar *event) | int chromatic1_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace chromatic1_names; | using namespace chromatic1_names; | |||
void chromatic1_RBshift(); | void chromatic1_RBshift(); | |||
void chromatic1_RBsearch(); | void chromatic1_RBsearch(); | |||
if (strmatch(event,"escape")) zd->zstat = -2; // escape key | if (strmatch(event,"escape")) zd->zstat = -2; // escape key | |||
if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | if (strmatch(event,"done")) zd->zstat = 1; // from edit_setup() or f_save() | |||
if (strmatch(event,"cancel")) zd->zstat = 2; // from f_open() | if (strmatch(event,"cancel")) zd->zstat = 2; // from f_open() | |||
if (zd->zstat) | if (zd->zstat) | |||
{ | { | |||
if (zd->zstat == 1) // done | if (zd->zstat == 1) // done | |||
{ | { | |||
edit_addhist("Red:%.1f %.1f %.1f Blue:%.1f %.1f %.1f", // edit params > edit hist | edit_addhist("Red:%.1f %.1f %.1f Blue:%.1f %.1f %.1f", // edit params > edit hist | |||
Rf1, Rf2, Rf3, Bf1, Bf2, Bf3); // log exif edit hist | Rf1, Rf2, Rf3, Bf1, Bf2, Bf3); // log metadata edit hist | |||
edit_done(0); | edit_done(0); | |||
} | } | |||
else edit_cancel(0); // discard edit | else edit_cancel(0); // discard edit | |||
zfree(pixcon); // free memory | zfree(pixcon); // free memory | |||
return 1; | return 1; | |||
} | } | |||
if (zstrstr("Rf1 Rf2 Rf3 Bf1 Bf2 Bf3",event)) | if (zstrstr("Rf1 Rf2 Rf3 Bf1 Bf2 Bf3",event)) | |||
{ | { | |||
zdialog_fetch(zd,"Rf1",Rf1); // get manually adjusted factors | zdialog_fetch(zd,"Rf1",Rf1); // get manually adjusted factors | |||
skipping to change at line 8492 | skipping to change at line 8499 | |||
int pcc = 3 * sizeof(float); // RGB pixel size | int pcc = 3 * sizeof(float); // RGB pixel size | |||
uint8 *Pmark; // pixel undo markers | uint8 *Pmark; // pixel undo markers | |||
int Vmark; // current Pmark value 0-255 | int Vmark; // current Pmark value 0-255 | |||
int Wcolor; // which color check button | int Wcolor; // which color check button | |||
int Bprox; // background proximity range | int Bprox; // background proximity range | |||
int Fusehue; // flag, use hue | int Fusehue; // flag, use hue | |||
} | } | |||
// menu function | // menu function | |||
void m_chromatic2(GtkWidget *, cchar *menu) | void m_chromatic2(GtkWidget *, ch *menu) | |||
{ | { | |||
using namespace chromatic2_names; | using namespace chromatic2_names; | |||
int chromatic2_dialog_event(zdialog* zd, cchar *event); | int chromatic2_dialog_event(zdialog* zd, ch *event); | |||
void chromatic2_mousefunc(); | void chromatic2_mousefunc(); | |||
cchar *title = "Chromatic Aberration"; | ch *title = "Chromatic Aberration"; | |||
int cc; | int cc; | |||
F1_help_topic = "chromatic 2"; | F1_help_topic = "chromatic 2"; | |||
Plog(1,"m_chromatic2 \n"); | Plog(1,"m_chromatic2 \n"); | |||
EFchromatic2.menuname = "Chromatic 2"; // setup edit | EFchromatic2.menuname = "Chromatic 2"; // setup edit | |||
EFchromatic2.menufunc = m_chromatic2; | EFchromatic2.menufunc = m_chromatic2; | |||
EFchromatic2.mousefunc = chromatic2_mousefunc; // mouse function | EFchromatic2.mousefunc = chromatic2_mousefunc; // mouse function | |||
EFchromatic2.Farea = 2; // select area OK | EFchromatic2.Farea = 2; // select area OK | |||
skipping to change at line 8574 | skipping to change at line 8581 | |||
Cmatch = 70; // match level % | Cmatch = 70; // match level % | |||
Bprox = 10; // background proximity | Bprox = 10; // background proximity | |||
Vmark = 0; // no marks yet | Vmark = 0; // no marks yet | |||
takeMouse(chromatic2_mousefunc,dragcursor); | takeMouse(chromatic2_mousefunc,dragcursor); | |||
return; | return; | |||
} | } | |||
// dialog event and completion function | // dialog event and completion function | |||
int chromatic2_dialog_event(zdialog *zd, cchar *event) | int chromatic2_dialog_event(zdialog *zd, ch *event) | |||
{ | { | |||
using namespace chromatic2_names; | using namespace chromatic2_names; | |||
void chromatic2_mousefunc(); | void chromatic2_mousefunc(); | |||
void chromatic2_repair(); | void chromatic2_repair(); | |||
int ii; | int ii; | |||
int px, py; | int px, py; | |||
float *pix1, *pix3; | float *pix1, *pix3; | |||
skipping to change at line 8663 | skipping to change at line 8670 | |||
return 1; | return 1; | |||
} | } | |||
// mouse function | // mouse function | |||
void chromatic2_mousefunc() | void chromatic2_mousefunc() | |||
{ | { | |||
using namespace chromatic2_names; | using namespace chromatic2_names; | |||
float *pix; | float *pix; | |||
char text[20]; | ch text[20]; | |||
if (! LMclick) return; | if (! LMclick) return; | |||
LMclick = 0; | LMclick = 0; | |||
if (! zd) return; | if (! zd) return; | |||
pix = PXBpix(E1pxm,Mxclick,Myclick); // pick new color from image | pix = PXBpix(E1pxm,Mxclick,Myclick); // pick new color from image | |||
snprintf(text,20,"%.0f|%.0f|%.0f",pix[0],pix[1],pix[2]); | snprintf(text,20,"%.0f|%.0f|%.0f",pix[0],pix[1],pix[2]); | |||
if (Wcolor == 1) { // chromatic color to fix | if (Wcolor == 1) { // chromatic color to fix | |||
Crgb[0] = pix[0]; | Crgb[0] = pix[0]; | |||
skipping to change at line 8705 | skipping to change at line 8712 | |||
// repair the chromatic aberraton | // repair the chromatic aberraton | |||
void chromatic2_repair() | void chromatic2_repair() | |||
{ | { | |||
using namespace chromatic2_names; | using namespace chromatic2_names; | |||
void * chromatic2_repair_wthread(void *arg); | void * chromatic2_repair_wthread(void *arg); | |||
float rmin, rmax; | float rmin, rmax; | |||
char text[20]; | ch text[20]; | |||
cchar *pp; | ch *pp; | |||
zdialog_fetch(zd,"Crgb",text,20); // get chromatic color to fix | zdialog_fetch(zd,"Crgb",text,20); // get chromatic color to fix | |||
pp = substring(text,'|',1); | pp = substring(text,'|',1); | |||
if (pp) Crgb[0] = atoi(pp); | if (pp) Crgb[0] = atoi(pp); | |||
pp = substring(text,'|',2); | pp = substring(text,'|',2); | |||
if (pp) Crgb[1] = atoi(pp); | if (pp) Crgb[1] = atoi(pp); | |||
pp = substring(text,'|',3); | pp = substring(text,'|',3); | |||
if (pp) Crgb[2] = atoi(pp); | if (pp) Crgb[2] = atoi(pp); | |||
zdialog_fetch(zd,"Rrgb",text,20); // get replacement color | zdialog_fetch(zd,"Rrgb",text,20); // get replacement color | |||
End of changes. 113 change blocks. | ||||
134 lines changed or deleted | 143 lines changed or added |