f.edit.cc (fotoxx-22.41) | : | f.edit.cc (fotoxx-22.50) | ||
---|---|---|---|---|
skipping to change at line 185 | skipping to change at line 185 | |||
py = pylo + thread; | py = pylo + thread; | |||
if (py >= pyhi) return 1; | if (py >= pyhi) return 1; | |||
} | } | |||
while (true) | while (true) | |||
{ | { | |||
px++; // next px/py | px++; // next px/py | |||
if (px >= pxhi) { | if (px >= pxhi) { | |||
px = pxlo; | px = pxlo; | |||
py += Nt; | py += Nt; | |||
if (py >= pyhi) return 1; | if (py >= pyhi) return 1; // end return | |||
} | } | |||
Pradius = (px - Mxposn) * (px - Mxposn); // get (px,py) discance from mouse center | Pradius = (px - Mxposn) * (px - Mxposn); // get (px,py) discance from mouse center | |||
Pradius += (py - Myposn) * (py - Myposn); | Pradius += (py - Myposn) * (py - Myposn); | |||
Pradius = sqrtf(Pradius); | Pradius = sqrtf(Pradius); | |||
if (Pradius < Mradius) break; // pixel within mouse radius, keep | if (Pradius < Mradius) break; // pixel within mouse radius, keep | |||
} | } | |||
blend = Cpow + (Epow - Cpow) * Pradius / Mradius; // Cpow to Epow for center to edge pixel | blend = Cpow + (Epow - Cpow) * Pradius / Mradius; // Cpow to Epow for center to edge pixel | |||
blend = blend * blend; // quadratic scale | blend = blend * blend; // quadratic scale | |||
skipping to change at line 5929 | skipping to change at line 5929 | |||
} | } | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// make a black & white or color positive or negative, or sepia image | // make a black & white or color positive or negative, or sepia image | |||
namespace colormode_names | namespace colormode_names | |||
{ | { | |||
editfunc EFcolormode; | editfunc EFcolormode; | |||
int mode; | int mode; | |||
float blend; | float mblend; | |||
} | } | |||
// menu function | // menu function | |||
void m_color_mode(GtkWidget *, cchar *menu) | void m_color_mode(GtkWidget *, cchar *menu) | |||
{ | { | |||
using namespace colormode_names; | using namespace colormode_names; | |||
int colormode_dialog_event(zdialog *zd, cchar *event); | int colormode_dialog_event(zdialog *zd, cchar *event); | |||
void * colormode_thread(void *); | void * colormode_thread(void *); | |||
F1_help_topic = "color mode"; | F1_help_topic = "color mode"; | |||
Plog(1,"m_color_mode \n"); | Plog(1,"m_color_mode \n"); | |||
EFcolormode.menuname = "Color Mode"; | EFcolormode.menuname = "Color Mode"; | |||
EFcolormode.menufunc = m_color_mode; | EFcolormode.menufunc = m_color_mode; | |||
EFcolormode.threadfunc = colormode_thread; | EFcolormode.threadfunc = colormode_thread; | |||
EFcolormode.FprevReq = 1; // use preview | EFcolormode.FprevReq = 1; // use preview | |||
EFcolormode.Farea = 2; // select area usable | EFcolormode.Farea = 2; // select area usable | |||
EFcolormode.Fpaintedits = 1; // allow paint edits 22.50 | ||||
EFcolormode.Frestart = 1; // allow restart | EFcolormode.Frestart = 1; // allow restart | |||
EFcolormode.Fscript = 1; // scripting supported | EFcolormode.Fscript = 1; // scripting supported | |||
if (! edit_setup(EFcolormode)) return; // setup edit | if (! edit_setup(EFcolormode)) return; // setup edit | |||
/*** | /*** | |||
_____________________________ | _____________________________ | |||
| Color Mode | | | Color Mode | | |||
| | | | | | |||
| [_] reset | // check boxes | | [_] reset | // check boxes | |||
skipping to change at line 5984 | skipping to change at line 5985 | |||
zdialog *zd = zdialog_new("Color Mode",Mwin,"OK","Cancel",null); | zdialog *zd = zdialog_new("Color Mode",Mwin,"OK","Cancel",null); | |||
EFcolormode.zd = zd; | EFcolormode.zd = zd; | |||
zdialog_add_widget(zd,"check","reset","dialog","reset"); | zdialog_add_widget(zd,"check","reset","dialog","reset"); | |||
zdialog_add_widget(zd,"check","b&wpos","dialog","black/white positive"); | zdialog_add_widget(zd,"check","b&wpos","dialog","black/white positive"); | |||
zdialog_add_widget(zd,"check","b&wneg","dialog","black/white negative"); | zdialog_add_widget(zd,"check","b&wneg","dialog","black/white negative"); | |||
zdialog_add_widget(zd,"check","colneg","dialog","color negative"); | zdialog_add_widget(zd,"check","colneg","dialog","color negative"); | |||
zdialog_add_widget(zd,"check","rgb-gbr","dialog","RGB -> GBR"); | zdialog_add_widget(zd,"check","rgb-gbr","dialog","RGB -> GBR"); | |||
zdialog_add_widget(zd,"check","rgb-brg","dialog","RGB -> BRG"); | zdialog_add_widget(zd,"check","rgb-brg","dialog","RGB -> BRG"); | |||
zdialog_add_widget(zd,"check","sepia","dialog","sepia"); | zdialog_add_widget(zd,"check","sepia","dialog","sepia"); | |||
zdialog_add_widget(zd,"hbox","hbblend","dialog"); | zdialog_add_widget(zd,"hbox","hbmblend","dialog"); | |||
zdialog_add_widget(zd,"label","lab0","hbblend","0%","space=5"); | zdialog_add_widget(zd,"label","lab0","hbmblend","0%","space=5"); | |||
zdialog_add_widget(zd,"hscale","blend","hbblend","0.0|1.0|0.01|1.0","expand") | zdialog_add_widget(zd,"hscale","mblend","hbmblend","0.0|1.0|0.01|1.0","expand | |||
; | "); | |||
zdialog_add_widget(zd,"label","lab100","hbblend","100%","space=5"); | zdialog_add_widget(zd,"label","lab100","hbmblend","100%","space=5"); | |||
zdialog_resize(zd,200,0); | zdialog_resize(zd,200,0); | |||
zdialog_run(zd,colormode_dialog_event,"save"); // run dialog - parallel | zdialog_run(zd,colormode_dialog_event,"save"); // run dialog - parallel | |||
return; | return; | |||
} | } | |||
// dialog event and completion callback function | // dialog event and completion callback function | |||
int colormode_dialog_event(zdialog *zd, cchar *event) | int colormode_dialog_event(zdialog *zd, cchar *event) | |||
skipping to change at line 6016 | skipping to change at line 6017 | |||
edit_fullsize(); // get full size image | edit_fullsize(); // get full size image | |||
thread_signal(); | thread_signal(); | |||
return 1; | return 1; | |||
} | } | |||
if (zd->zstat) | if (zd->zstat) | |||
{ | { | |||
if (zd->zstat == 1) { | if (zd->zstat == 1) { | |||
edit_fullsize(); // get full size image | edit_fullsize(); // get full size image | |||
thread_signal(); | thread_signal(); | |||
edit_addhist("mode:%d blend:%.2f",mode,blend); // edit params > edit hist | edit_addhist("mode:%d blend:%.2f",mode,mblend); // edit params > edit hist | |||
edit_done(0); // commit edit | edit_done(0); // commit edit | |||
} | } | |||
else edit_cancel(0); // discard edit | else edit_cancel(0); // discard edit | |||
return 1; | return 1; | |||
} | } | |||
if (strmatch(event,"focus")) return 1; | if (strmatch(event,"focus")) return 1; | |||
if (zstrstr("reset b&wpos b&wneg colneg rgb-gbr rgb-brg sepia",event)) | if (zstrstr("reset b&wpos b&wneg colneg rgb-gbr rgb-brg sepia",event)) | |||
{ | { | |||
skipping to change at line 6044 | skipping to change at line 6045 | |||
zdialog_stuff(zd,event,1); | zdialog_stuff(zd,event,1); | |||
if (strmatch(event,"reset")) mode = 0; | if (strmatch(event,"reset")) mode = 0; | |||
if (strmatch(event,"b&wpos")) mode = 1; | if (strmatch(event,"b&wpos")) mode = 1; | |||
if (strmatch(event,"b&wneg")) mode = 2; | if (strmatch(event,"b&wneg")) mode = 2; | |||
if (strmatch(event,"colneg")) mode = 3; | if (strmatch(event,"colneg")) mode = 3; | |||
if (strmatch(event,"rgb-gbr")) mode = 4; | if (strmatch(event,"rgb-gbr")) mode = 4; | |||
if (strmatch(event,"rgb-brg")) mode = 5; | if (strmatch(event,"rgb-brg")) mode = 5; | |||
if (strmatch(event,"sepia")) mode = 6; | if (strmatch(event,"sepia")) mode = 6; | |||
} | } | |||
zdialog_fetch(zd,"blend",blend); | zdialog_fetch(zd,"mblend",mblend); | |||
if (mode == 0) { | if (mode == 0) { | |||
edit_reset(); | edit_reset(); | |||
return 1; | return 1; | |||
} | } | |||
thread_signal(); | thread_signal(); | |||
return 1; | return 1; | |||
} | } | |||
// thread function | // thread function | |||
void * colormode_thread(void *) | void * colormode_thread(void *) | |||
{ | { | |||
using namespace colormode_names; | using namespace colormode_names; | |||
void * colormode_wthread(void *arg); | void * colormode_wthread(void *arg); | |||
get_edit_pixels_init(NWT,0); // initz. pixel loop 22.50 | ||||
do_wthreads(colormode_wthread,NWT); // worker threads | do_wthreads(colormode_wthread,NWT); // worker threads | |||
CEF->Fmods++; // image modified | CEF->Fmods++; // image modified | |||
CEF->Fsaved = 0; // not saved | CEF->Fsaved = 0; // not saved | |||
Fpaint2(); // update window | if (! Fpaintedits) Fpaint2(); // update window | |||
return 0; | return 0; | |||
} | } | |||
// worker thread functions | // worker thread functions | |||
void * colormode_wthread(void *arg) | void * colormode_wthread(void *arg) | |||
{ | { | |||
using namespace colormode_names; | using namespace colormode_names; | |||
int index = *((int *) (arg)); | int index = *((int *) (arg)); | |||
int E3ww, E3hh; | int px, py, Fend; | |||
int ii, dist, px, py; | float R1, G1, B1, R3, G3, B3, R9, G9, B9; | |||
float red1, green1, blue1; | ||||
float red3, green3, blue3; | ||||
float *pix1, *pix3; | float *pix1, *pix3; | |||
float brite, ff1, ff2; | float brite, ff1, ff2; | |||
float max$; | float blend, max$; | |||
E3ww = E3pxm->ww; | while (true) | |||
E3hh = E3pxm->hh; | ||||
dist = 0; | ||||
// stop compiler warnings | ||||
for (py = index; py < E3hh; py += NWT) | ||||
for (px = 0; px < E3ww; px++) | ||||
{ | { | |||
if (sa_stat == 3) { | Fend = get_edit_pixels(index,px,py,blend); | |||
// select area active | // 22.50 | |||
ii = py * E3ww + px; | if (Fend) break; | |||
dist = sa_pixmap[ii]; | if (blend == 0) continue; | |||
// distance from edge | ||||
if (! dist) continue; | ||||
// pixel outside area | ||||
} | ||||
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 | |||
red1 = pix1[0]; | R1 = pix1[0]; | |||
green1 = pix1[1]; | G1 = pix1[1]; | |||
blue1 = pix1[2]; | B1 = pix1[2]; | |||
red3 = pix3[0]; | R3 = R9 = pix3[0]; | |||
green3 = pix3[1]; | G3 = G9 = pix3[1]; | |||
blue3 = pix3[2]; | B3 = B9 = pix3[2]; | |||
switch (mode) | switch (mode) | |||
{ | { | |||
case 1: { // black and white positive | case 1: { // black and white positive | |||
red3 = green3 = blue3 = 0.333 * (red1 + green1 + blue1); | R9 = G9 = B9 = 0.333 * (R1 + G1 + B1); | |||
break; | break; | |||
} | } | |||
case 2: { // black and white negative | case 2: { // black and white negative | |||
red3 = green3 = blue3 = 255.9 - 0.333 * (red1 + green1 + blue1); | R9 = G9 = B9 = 255.9 - 0.333 * (R1 + G1 + B1); | |||
break; | break; | |||
} | } | |||
case 3: { // color negative | case 3: { // color negative | |||
red3 = 255.9 - red1; | R9 = 255.9 - R1; | |||
green3 = 255.9 - green1; | G9 = 255.9 - G1; | |||
blue3 = 255.9 - blue1; | B9 = 255.9 - B1; | |||
break; | break; | |||
} | } | |||
case 4: { // RGB - GBR | case 4: { // RGB - GBR | |||
red3 = green1; | R9 = G1; | |||
green3 = blue1; | G9 = B1; | |||
blue3 = red1; | B9 = R1; | |||
break; | break; | |||
} | } | |||
case 5: { // RGB - BRG | case 5: { // RGB - BRG | |||
red3 = blue1; | R9 = B1; | |||
green3 = red1; | G9 = R1; | |||
blue3 = green1; | B9 = G1; | |||
break; | break; | |||
} | } | |||
case 6: { // sepia | case 6: { // sepia | |||
brite = red1; | brite = R1; | |||
if (green1 > brite) brite = green1; | if (G1 > brite) brite = G1; | |||
// max. color level | // max. color level | |||
if (blue1 > brite) brite = blue1; | if (B1 > brite) brite = B1; | |||
brite = 0.2 * brite + 0.2666 * (red1 + green1 + blue1); | brite = 0.2 * brite + 0.2666 * (R1 + G1 + B1); | |||
// brightness, 0.0 ... 255.9 | // brightness, 0.0 ... 255.9 | |||
brite = brite * 0.003906; // 0.0 ... 1.0 | brite = brite * 0.003906; // 0.0 ... 1.0 | |||
ff1 = 1.0 - 0.7 * brite; // sepia part, 1.0 ... 0.3 | ff1 = 1.0 - 0.7 * brite; // sepia part, 1.0 ... 0.3 | |||
ff2 = 1.0 - ff1; // B & W part, 0.0 ... 0.7 | ff2 = 1.0 - ff1; // B & W part, 0.0 ... 0.7 | |||
red3 = ff1 * 255.0 + ff2 * 256; | R9 = ff1 * 255.0 + ff2 * 256; | |||
// combine max. sepia with white | // combine max. sepia with white | |||
green3 = ff1 * 150.0 + ff2 * 256; | G9 = ff1 * 150.0 + ff2 * 256; | |||
blue3 = ff1 * 46.0 + ff2 * 256; | B9 = ff1 * 46.0 + ff2 * 256; | |||
brite = 0.8333 * (brite + 0.2); // add brightness at low end | brite = 0.8333 * (brite + 0.2); // add brightness at low end | |||
red3 = red3 * brite; | R9 = R9 * brite; | |||
// output = combined color * brightness | // output = combined color * brightness | |||
green3 = green3 * brite; | G9 = G9 * brite; | |||
blue3 = blue3 * brite; | B9 = B9 * brite; | |||
break; | break; | |||
} | } | |||
} | } | |||
RGBFIX(red3,green3,blue3) // prevent underflow/overflow | RGBFIX(R9,G9,B9) // prevent underflow/overflow | |||
if (sa_stat == 3 && dist < sa_blendwidth) { | if (mblend < 1.0) { | |||
// blend changes over blendwidth | // image blend slider | |||
ff1 = sa_blendfunc(dist); | ff1 = mblend; | |||
ff2 = 1.0 - ff1; | ff2 = 1.0 - ff1; | |||
red3 = ff1 * red3 + ff2 * red1; | R9 = ff1 * R9 + ff2 * R1; | |||
green3 = ff1 * green3 + ff2 * green1; | // blend input and edited images | |||
blue3 = ff1 * blue3 + ff2 * blue1; | G9 = ff1 * G9 + ff2 * G1; | |||
B9 = ff1 * B9 + ff2 * B1; | ||||
} | } | |||
if (blend < 1.0) { | if (Fpaintedits) | |||
// blend slider | // mouse paint edit 22.50 | |||
ff1 = blend; | { | |||
ff2 = 1.0 - ff1; | if (blend > 0) | |||
red3 = ff1 * red3 + ff2 * red1; | { | |||
green3 = ff1 * green3 + ff2 * green1; | // increase edit | |||
blue3 = ff1 * blue3 + ff2 * blue1; | R3 = blend * R9 + (1-blend) * R3; | |||
G3 = blend * G9 + (1-blend) * G3; | ||||
B3 = blend * B9 + (1-blend) * B3; | ||||
} | ||||
else if (blend < 0) | ||||
{ | ||||
// decrease edit | ||||
R3 = -blend * R1 + (1+blend) * R3; | ||||
G3 = -blend * G1 + (1+blend) * G3; | ||||
B3 = -blend * B1 + (1+blend) * B3; | ||||
} | ||||
} | } | |||
pix3[0] = red3; | else | |||
pix3[1] = green3; | // full image edit | |||
pix3[2] = blue3; | { | |||
R3 = blend * R9 + (1-blend) * R1; | ||||
G3 = blend * G9 + (1-blend) * G1; | ||||
B3 = blend * B9 + (1-blend) * B1; | ||||
} | ||||
pix3[0] = R3; | ||||
pix3[1] = G3; | ||||
pix3[2] = B3; | ||||
} | } | |||
return 0; | return 0; | |||
} | } | |||
/******************************************************************************* */ | /******************************************************************************* */ | |||
// Pixel paint function - paint individual pixels with the mouse. | // Pixel paint function - paint individual pixels with the mouse. | |||
// The mouse circle paints a selected color. | // The mouse circle paints a selected color. | |||
skipping to change at line 9074 | skipping to change at line 9082 | |||
EFplugin.menufunc = m_run_plugin; | EFplugin.menufunc = m_run_plugin; | |||
EFplugin.menuname = "plugin"; | EFplugin.menuname = "plugin"; | |||
if (! edit_setup(EFplugin)) return; // start edit function | if (! edit_setup(EFplugin)) return; // start edit function | |||
snprintf(pluginfile,100,"%s/plugfile.tif",temp_folder); // .../tempfiles-nnnnnn/plugfile.tif | snprintf(pluginfile,100,"%s/plugfile.tif",temp_folder); // .../tempfiles-nnnnnn/plugfile.tif | |||
err = PXM_save(E1pxm,pluginfile,8,100,1); // E1 >> plugin_file | err = PXM_save(E1pxm,pluginfile,8,100,1); // E1 >> plugin_file | |||
if (err) goto FAIL; | if (err) goto FAIL; | |||
zd = zmessage_post(Mwin,"20/20",0,"Plugin working ..."); | zd = zmessage_post_bold(Mwin,"20/20",0,"Plugin working ..."); | |||
repl_1str(plugincommand,command,"%s",pluginfile); // command filename | repl_1str(plugincommand,command,"%s",pluginfile); // command filename | |||
if (! regfile(pluginfile,&statB)) goto FAIL; // image file mod time | if (! regfile(pluginfile,&statB)) goto FAIL; // image file mod time | |||
modtime1 = statB.st_mtime; | modtime1 = statB.st_mtime; | |||
err = zshell("log ack",command); // execute plugin command | err = zshell("log ack",command); // execute plugin command | |||
if (err) goto FAIL; | if (err) goto FAIL; | |||
if (! regfile(pluginfile,&statB)) goto FAIL; // check if new file made | if (! regfile(pluginfile,&statB)) goto FAIL; // check if new file made | |||
skipping to change at line 9102 | skipping to change at line 9110 | |||
if (! pxmtemp) { | if (! pxmtemp) { | |||
zmessageACK(Mwin,"plugin failed"); | zmessageACK(Mwin,"plugin failed"); | |||
goto FAIL; | goto FAIL; | |||
} | } | |||
PXM_free(E3pxm); // plugin_file >> E3 | PXM_free(E3pxm); // plugin_file >> E3 | |||
E3pxm = pxmtemp; | E3pxm = pxmtemp; | |||
CEF->Fmods++; // assume image was modified | CEF->Fmods++; // assume image was modified | |||
CEF->Fsaved = 0; | CEF->Fsaved = 0; | |||
edit_addhist("%s",menu); | edit_addhist("plugin: %s",menu); | |||
edit_done(0); | edit_done(0); | |||
goto RETURN; | goto RETURN; | |||
FAIL: | FAIL: | |||
edit_cancel(0); | edit_cancel(0); | |||
RETURN: | RETURN: | |||
if (zd) zdialog_free(zd); | if (zd) zdialog_free(zd); | |||
return; | return; | |||
} | } | |||
End of changes. 28 change blocks. | ||||
82 lines changed or deleted | 91 lines changed or added |