From 04031cc2a664d2a6d9d2a37954c55cc68742d78c Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sun, 28 Oct 2018 12:36:26 -0600 Subject: [PATCH] rework histogram_bezier, init wm icon set_icon(gg), update de.po+msg/txt --- cinelerra-5.1/cinelerra/pluginclient.C | 2 + cinelerra-5.1/guicast/bcresources.C | 6 + cinelerra-5.1/guicast/bcresources.h | 3 + cinelerra-5.1/guicast/bcwindowbase.C | 2 +- cinelerra-5.1/guicast/images/default_icon.png | Bin 0 -> 1987 bytes .../guicast/images/default_icon_png.h | 134 ++++ cinelerra-5.1/guicast/linklist.h | 5 +- cinelerra-5.1/msg/txt | 18 +- .../plugins/histogram_bezier/bistogram.C | 647 +++++++---------- .../plugins/histogram_bezier/bistogram.h | 3 + .../plugins/histogram_bezier/bistogram.inc | 3 +- .../histogram_bezier/bistogramconfig.C | 202 +++--- .../histogram_bezier/bistogramconfig.h | 9 +- .../histogram_bezier/bistogramwindow.C | 671 +++++++----------- .../histogram_bezier/bistogramwindow.h | 21 +- cinelerra-5.1/po/de.po | 10 +- 16 files changed, 811 insertions(+), 925 deletions(-) create mode 100644 cinelerra-5.1/guicast/images/default_icon.png create mode 100644 cinelerra-5.1/guicast/images/default_icon_png.h diff --git a/cinelerra-5.1/cinelerra/pluginclient.C b/cinelerra-5.1/cinelerra/pluginclient.C index 7f1fdd04..606f83d9 100644 --- a/cinelerra-5.1/cinelerra/pluginclient.C +++ b/cinelerra-5.1/cinelerra/pluginclient.C @@ -81,6 +81,8 @@ void PluginClientThread::run() if(window) { window->lock_window("PluginClientThread::run"); window->create_objects(); + VFrame *picon = client->server->get_picon(); + if( picon ) window->set_icon(picon); window->unlock_window(); /* Only set it here so tracking doesn't update it until everything is created. */ diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C index 5746e6c2..43a713e7 100644 --- a/cinelerra-5.1/guicast/bcresources.C +++ b/cinelerra-5.1/guicast/bcresources.C @@ -360,6 +360,7 @@ VFrame *BC_Resources::default_progress_images[2] = { 0, }; VFrame *BC_Resources::default_medium_7segment[20] = { 0, }; VFrame *BC_Resources::default_vscroll_data[10] = { 0, }; VFrame *BC_Resources::default_hscroll_data[10] = { 0, }; +VFrame *BC_Resources::default_icon_img = 0; BC_Resources::BC_Resources() { @@ -712,6 +713,9 @@ new_vframes(10,default_vscroll_data, new VFramePng(vscroll_right_hi_png), new VFramePng(vscroll_right_dn_png)); +#include "images/default_icon_png.h" + default_icon_img = new VFramePng(default_icon_png); + type_to_icon = default_type_to_icon; bar_data = default_bar; check = default_check_image; @@ -723,6 +727,7 @@ new_vframes(10,default_vscroll_data, listbox_dn = default_listbox_dn; hscroll_data = default_hscroll_data; vscroll_data = default_vscroll_data; + default_icon = default_icon_img; listbox_title_overlap = 0; listbox_title_margin = 0; @@ -954,6 +959,7 @@ BC_Resources::~BC_Resources() fontlist->remove_all_objects(); delete fontlist; } + delete default_icon_img; finit_font_defs(); } diff --git a/cinelerra-5.1/guicast/bcresources.h b/cinelerra-5.1/guicast/bcresources.h index f2339ed0..369d196c 100644 --- a/cinelerra-5.1/guicast/bcresources.h +++ b/cinelerra-5.1/guicast/bcresources.h @@ -185,6 +185,8 @@ public: static VFrame *bg_image; static VFrame *menu_bg; +// default icon + VFrame *default_icon; // Buttons VFrame **ok_images; VFrame **cancel_images; @@ -402,6 +404,7 @@ public: static VFrame *default_medium_7segment[20]; static VFrame *default_vscroll_data[10]; static VFrame *default_hscroll_data[10]; + static VFrame *default_icon_img; // Make VFrame use shm int vframe_shm; diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index 621c560a..1ef0d593 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -62,7 +62,6 @@ #include #include - BC_ResizeCall::BC_ResizeCall(int w, int h) { this->w = w; @@ -547,6 +546,7 @@ int BC_WindowBase::create_window(BC_WindowBase *parent_window, const char *title PropModeReplace, (unsigned char *)&XGroupLeader, true); } init_im(); + set_icon(get_resources()->default_icon); } #ifdef HAVE_LIBXXF86VM diff --git a/cinelerra-5.1/guicast/images/default_icon.png b/cinelerra-5.1/guicast/images/default_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6070443ac22b0921c7c22d1abee08db7f5aa7062 GIT binary patch literal 1987 zcmV;!2R!(RP){Dxe@#&G97d z47(Qq0zzP80ziDckp6u*gw#wr5>n zTMPEyaqH`jLjVZCCN&#$&1PJi}LcALJYw3nVvi5poD`<~GX{C{Pq(g*Kn5&I`B&4s|6Cg(wXY(Yn#{F&>;I zdmLQZfw+TByA~5z0Mrl{143G(*`2I0Q7a>6ohKQok0W@|f>%?pdmIc>;v#(ZhzYBp za8`;Fz1E4}I#xq4WAoza-uH{cziV*mQ0m^9gyw@WsPxS+F>EDCUDlWcNw?7)Hh#W%guydcRN1cd5} za46b55D94Ub*4UE*^$G&08q}4&FBC+Oe#>KPQB1pnmk75{k3 zN4@987Zk6)bTK6WR7v}R?Z{#fO7QvXzvY>P2Y?SgsXfq1;5Q$i9xXfo{OzB_zn&6B zfLg{;svXsi0HF{E@BVps<|p60K`p@T(TWx?WG;69nHMvko`GL}^dyp3XRG#k{cE?r z%Uduqu}gL6y#IS!|JQ#h_|a?U4yhay6NEa9XaaU771xe4)>>iH61^f^13s18J;i27 znG^mcRk@|CaT4gYq9ut}OM4F5oQe}2*(d=NQGEa98(aXKduft{ktn=&Pc$!7G0Xno z^|J-BtSod|cH*>&-Kj|QfJdnu=!Hr@R4o}y5EA-M-mEB2i!SI%h*E~&QGrubWKsYR z=&S@3#kBb6e|WN;{>ImD04S8)d!S*u*x0W=JmJ&Z{n9`F?(oJYE3Nm_0oM&~hwlaJ zupDNmfVl7?CK&G^sVeI5;vF7%pbmNPt#90T3kJBk5Wo22sVg9x2Zf%LiKh#Gy!owL zvvM&3-}zurcr7hHbWZpzb-7;w!IeZW+)IL%6i=@=K`dgyTV0VVZ5%lHb!MR&g1AhD zkJfD_S_73{R8dn(9E*?kIYL6!Jdjb=tj?I66^?){CSdz~t^%hrQ)fIAsGSlU9V&pg zUOwaPKbd!a_S+|q-bD#xAx-Xj|96jj*AKsaSvIjz6I(xF``}l;c;Lm)KU=f%OJDF# z9;}!6y;p9Zx$*hs7mgk;B7=rQ`c1s^+S8s79ah%%!+M-n0^A~dE zuc3uvLW}@Dd2pWU2=&V>6`9!BfR$cu`z zRgo*zStAZbT~Y+qsio;XpxifFGL5BnV9fvB1MFutZAW6cHF<^Moa*N8Wo@}oOc$b*JK^IzO&yC(;f@q|QK*=ScJIhs z#4|yN_j+Ihq5E>A$p5-ipeZ5gT0Ab27bxxURy#Kx5N$!6JdlOTyAhWzb5csj9>AnP zt_Rp_WF2kDw%P6Guj|)d$S+D<%TjetGcG-dM;lH9wkGSPLWcJpq3PAGyK|4=0p&&s z+%5cr54RPS$pSPga+;9q&9nAf#N`NcBPI*HUp z$opj0t2Myrko6YQE&!RXWo9dG8cWK=-TGBW*cQuab9cI5T zin9wb0H=C1}B77fEkiU})I zbg&a2N~H<^DUk1b3GZG?pi2AyLd1CJbg9Nnle;wOF%6BqG#o!c;Q=AGW@gXt=l`-H VK class List { TYPE *split(int (*cmpr)(TYPE *a, TYPE *b),TYPE *l, TYPE *r); - void sort(int (*cmpr)(TYPE *a, TYPE *b),TYPE *ll, TYPE *rr); static int cmpr(TYPE *a, TYPE *b) { if( *a == *b ) return 0; return *a > *b ? 1 : -1; @@ -44,8 +43,8 @@ public: return p ? i : -1; } void swap(TYPE *item1, TYPE *item2); - void sort(int (*cmp)(TYPE *a, TYPE *b) = 0) { - return sort(cmp ? cmp : cmpr,0,0); } + void sort(TYPE *ap=0, TYPE *bp=0) { return sort(cmpr,ap,bp); } + void sort(int (*cmp)(TYPE *a, TYPE *b), TYPE *ap=0, TYPE *bp=0); List() { first = last = 0; } virtual ~List() { while(last) delete last; } }; diff --git a/cinelerra-5.1/msg/txt b/cinelerra-5.1/msg/txt index 9a0e51a6..222bc738 100644 --- a/cinelerra-5.1/msg/txt +++ b/cinelerra-5.1/msg/txt @@ -6,15 +6,25 @@ Email cinelerra@lists.cinelerra-cv.org 4 help. For usage help, refer to the following: https://cinelerra-cv.org/docs/cinelerra_cv_manual_en.html https://cinelerra-cv.org/five/Features5.pdf - http://beccatoria.dreamwidth.org/144288.html#cutid2 http://g-raffa.eu/Cinelerra/HOWTO/basics.html -Cinfinity icons selected in Preferences (Creative Common - By https://creativecommons.org/licenses/by/3.0/) +Cinfinity icons selected in Preferences Sam (CC BY 3.0, + https://creativecommons.org/licenses/by/3.0/) +Neophyte theme selected in Preferences by Olaf Wolff (CC BY 4.0, + https://creativecommons.org/licenses/by/4.0/) +. +Oct 2018 New features of note: + Title plugin has unlimited number of characters allowed. + Histogram Bezier bug fixes and some improvements applied. + Trim Feature enhancement with drag handle and split look. + Additional ffmpeg plugins available (FF icon for now). + Dynamic keyframes implemented so can use large numbers. + Color correction+others highlighted with expand subtrees. + Autos, like fade, allow for textbox input & tooltip values. . Sept 2018 New Features of note: Motion plugins now have more visible stippled lines. New Export Project option; h26x_mp3 audio format available, - Overlays Winow toggle on/off XYZ for Camera/Projector. + Overlays Winow toggle on/off XYZ for Camera/Projector. Patchbay Expander icon moved up to allow for better usage. . July/Aug 2018 New Features of note: diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogram.C b/cinelerra-5.1/plugins/histogram_bezier/bistogram.C index 1f786f95..2ad9c17d 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogram.C +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogram.C @@ -49,10 +49,8 @@ REGISTER_PLUGIN(HistogramMain) HistogramMain::HistogramMain(PluginServer *server) : PluginVClient(server) { - engine = 0; - for(int i = 0; i < HISTOGRAM_MODES; i++) - { + for( int i=0; iwindow; window->lock_window("HistogramMain::render_gui"); @@ -133,8 +134,7 @@ void HistogramMain::save_data(KeyFrame *keyframe) char string[BCTEXTLEN]; - for(int i = 0; i < HISTOGRAM_MODES; i++) - { + for( int i=0; ix); output.tag.set_property("Y", current->y); @@ -202,63 +200,41 @@ void HistogramMain::read_data(KeyFrame *keyframe) int current_input_mode = 0; - while(!result) - { - result = input.read_tag(); - - if(!result) - { - if(input.tag.title_is("HISTOGRAM")) - { - char string[BCTEXTLEN]; - for(int i = 0; i < HISTOGRAM_MODES; i++) - { - sprintf(string, "OUTPUT_MIN_%d", i); - config.output_min[i] = input.tag.get_property(string, config.output_min[i]); - sprintf(string, "OUTPUT_MAX_%d", i); - config.output_max[i] = input.tag.get_property(string, config.output_max[i]); + while( !(result = input.read_tag()) ) { + if( input.tag.title_is("HISTOGRAM") ) { + char string[BCTEXTLEN]; + for( int i=0; ilast) - delete points->last; - while(!result) - { - result = input.read_tag(); - if(!result) - { - if(input.tag.title_is("/POINTS")) - { - break; - } - else - if(input.tag.title_is("POINT")) - { - points->insert( - input.tag.get_property("X", 0.0), - input.tag.get_property("Y", 0.0)); - points->last->gradient = - input.tag.get_property("GRADIENT", 1.0); - points->last->xoffset_left = - input.tag.get_property("XOFFSET_LEFT", -0.02); - points->last->xoffset_right = - input.tag.get_property("XOFFSET_RIGHT", 0.02); - } - } + config.automatic = input.tag.get_property("AUTOMATIC", config.automatic); + config.threshold = input.tag.get_property("THRESHOLD", config.threshold); + config.split = input.tag.get_property("SPLIT", config.split); + config.smoothMode = input.tag.get_property("INTERPOLATION", config.smoothMode); + } + else if( input.tag.title_is("POINTS") ) { + if( current_input_mode < HISTOGRAM_MODES ) { + HistogramPoints *points = &config.points[current_input_mode]; + while( points->last ) + delete points->last; + while( !(result = input.read_tag()) ) { + if( input.tag.title_is("/POINTS") ) break; + if(input.tag.title_is("POINT") ) { + points->insert( + input.tag.get_property("X", 0.0), + input.tag.get_property("Y", 0.0)); + points->last->gradient = + input.tag.get_property("GRADIENT", 1.0); + points->last->xoffset_left = + input.tag.get_property("XOFFSET_LEFT", -0.02); + points->last->xoffset_right = + input.tag.get_property("XOFFSET_RIGHT", 0.02); } - } - current_input_mode++; + ++current_input_mode; } } } @@ -297,8 +273,8 @@ float HistogramMain::calculate_linear(float input, HistogramPoints *points = &config.points[subscript]; HistogramPoint *current = points->first; int done = 0; - while(current && !done) { - if(current->x > input) { + while( current && !done ) { + if( current->x > input ) { x2 = current->x; y2 = current->y; grad2 = current->gradient; @@ -311,8 +287,8 @@ float HistogramMain::calculate_linear(float input, current = points->last; done = 0; - while(current && !done) { - if(current->x <= input) { + while( current && !done ) { + if( current->x <= input ) { x1 = current->x; y1 = current->y; grad1 = current->gradient; @@ -323,24 +299,18 @@ float HistogramMain::calculate_linear(float input, current = PREVIOUS; } - - - - if(!EQUIV(x2 - x1, 0)) - { - if (config.smoothMode == HISTOGRAM_LINEAR) + if( !EQUIV(x2 - x1, 0) ) { + if( config.smoothMode == HISTOGRAM_LINEAR ) output = (input - x1) * (y2 - y1) / (x2 - x1) + y1; - else if (config.smoothMode == HISTOGRAM_POLYNOMINAL) - { + else if( config.smoothMode == HISTOGRAM_POLYNOMINAL ) { /* Construct third grade polynom between every two points */ float dx = x2 - x1; float dy = y2 - y1; float delx = input - x1; output = (grad2 * dx + grad1 * dx - 2*dy) / (dx * dx * dx) * delx * delx * delx + - (3*dy - 2* grad1*dx - grad2*dx) / (dx * dx) * delx * delx + grad1*delx + y1; + (3*dy - 2* grad1*dx - grad2*dx) / (dx * dx) * delx * delx + grad1*delx + y1; } - else if (config.smoothMode == HISTOGRAM_BEZIER) - { + else if( config.smoothMode == HISTOGRAM_BEZIER ) { /* Using standart DeCasteljau algorithm */ float y1right = y1 + grad1 * x1right; float y2left = y2 + grad2 * x2left; @@ -361,7 +331,7 @@ float HistogramMain::calculate_linear(float input, } // Apply value curve - if(use_value) { + if( use_value ) { output = calculate_linear(output, HISTOGRAM_VALUE, 0); } @@ -376,12 +346,14 @@ float HistogramMain::calculate_linear(float input, float HistogramMain::calculate_smooth(float input, int subscript) { - float x_f = (input - HIST_MIN_INPUT) * HISTOGRAM_SLOTS / FLOAT_RANGE; + int bins = slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100; + int bins1 = bins-1; + float x_f = (input - HIST_MIN_INPUT) * bins / FLOAT_RANGE; int x_i1 = (int)x_f; int x_i2 = x_i1 + 1; - CLAMP(x_i1, 0, HISTOGRAM_SLOTS-1); - CLAMP(x_i2, 0, HISTOGRAM_SLOTS-1); - CLAMP(x_f, 0, HISTOGRAM_SLOTS-1); + CLAMP(x_i1, 0, bins1); + CLAMP(x_i2, 0, bins1); + CLAMP(x_f, 0, bins1); float smooth1 = smoothed[subscript][x_i1]; float smooth2 = smoothed[subscript][x_i2]; @@ -393,39 +365,47 @@ float HistogramMain::calculate_smooth(float input, int subscript) void HistogramMain::calculate_histogram(VFrame *data) { + int color_model = data->get_color_model(); + int pix_sz = BC_CModels::calculate_pixelsize(color_model); + int comp_sz = pix_sz / BC_CModels::components(color_model); + int needed_slots = comp_sz > 1 ? 0x10000 : 0x100; + if( slots != needed_slots ) { + reset(); + slots = needed_slots; + } + int bins = slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100; + if( !accum[0] ) { + for( int i=0; iget_w() * data->get_h() * pix_sz / 0x80000 + 2; + int smps = get_project_smp(); + if( cpus > smps ) cpus = smps; + engine = new HistogramEngine(this, cpus, cpus); } engine->process_packages(HistogramEngine::HISTOGRAM, data); - for(int i = 0; i < engine->get_total_clients(); i++) { + for( int i=0; iget_total_clients(); ++i ) { HistogramUnit *unit = (HistogramUnit*)engine->get_client(i); - if(i == 0) { - for(int j = 0; j < HISTOGRAM_MODES; j++) - memcpy(accum[j], unit->accum[j], sizeof(int) * HISTOGRAM_SLOTS); + if( i == 0 ) { + for( int j=0; jaccum[j], sizeof(int)*bins); } else { - for(int j = 0; j < HISTOGRAM_MODES; j++) { - int *out = accum[j]; - int *in = unit->accum[j]; - for(int k = 0; k < HISTOGRAM_SLOTS; k++) - out[k] += in[k]; + for( int j=0; jaccum[j]; + for( int k=0; kaccum[i]; int pixels = data->get_w() * data->get_h(); float white_fraction = 1.0 - (1.0 - config.threshold) / 2; @@ -444,22 +425,21 @@ void HistogramMain::calculate_automatic(VFrame *data) int total = 0; float max_level = 1.0; float min_level = 0.0; - // Get histogram slot above threshold of pixels - for(int j = 0; j < HISTOGRAM_SLOTS; j++) { + for( int j=0; j= threshold) { - max_level = (float)j / HISTOGRAM_SLOTS * FLOAT_RANGE + HIST_MIN_INPUT; + if( total >= threshold ) { + max_level = (float)j/bins * FLOAT_RANGE + HIST_MIN_INPUT; break; } } // Get slot below 99% of pixels total = 0; - for(int j = HISTOGRAM_SLOTS - 1; j >= 0; j--) { + for( int j=bins; --j>=0; ) { total += accum[j]; - if(total >= threshold) { - min_level = (float)j / HISTOGRAM_SLOTS * FLOAT_RANGE + HIST_MIN_INPUT; + if( total >= threshold ) { + min_level = (float)j/bins * FLOAT_RANGE + HIST_MIN_INPUT; break; } } @@ -470,21 +450,24 @@ void HistogramMain::calculate_automatic(VFrame *data) int HistogramMain::process_realtime(VFrame *input_ptr, VFrame *output_ptr) { -SET_TRACE - int need_reconfigure = load_configuration(); -SET_TRACE - - if(!engine) engine = new HistogramEngine(this, - get_project_smp() + 1, - get_project_smp() + 1); this->input = input_ptr; this->output = output_ptr; - send_render_gui(input_ptr); + int need_reconfigure = load_configuration(); + int color_model = input->get_color_model(); + int pix_sz = BC_CModels::calculate_pixelsize(color_model); + int comp_sz = pix_sz / BC_CModels::components(color_model); + int needed_slots = comp_sz > 1 ? 0x10000 : 0x100; + if( slots != needed_slots ) { + reset(); + slots = needed_slots; + need_reconfigure = 1; + } + + send_render_gui(input); - if(input_ptr->get_rows()[0] != output_ptr->get_rows()[0]) - { - output_ptr->copy_from(input_ptr); + if( input->get_rows()[0] != output_ptr->get_rows()[0] ) { + output_ptr->copy_from(input); } SET_TRACE @@ -496,17 +479,23 @@ SET_TRACE if( need_reconfigure ) { SET_TRACE // Calculate new curves - if(config.automatic) { + if( config.automatic ) { calculate_automatic(input); } SET_TRACE // Generate transfer tables for integer colormodels. - for(int i = 0; i < 3; i++) + for( int i=0; i<3; ++i ) tabulate_curve(i, 1); SET_TRACE } + if( !engine ) { + int cpus = input->get_w() * input->get_h() * pix_sz / 0x80000 + 2; + int smps = get_project_smp(); + if( cpus > smps ) cpus = smps; + engine = new HistogramEngine(this, cpus, cpus); + } // Apply histogram engine->process_packages(HistogramEngine::APPLY, input); @@ -516,48 +505,36 @@ SET_TRACE void HistogramMain::tabulate_curve(int subscript, int use_value) { - int i; + int bins = slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100; if(!lookup[subscript]) - lookup[subscript] = new int[HISTOGRAM_SLOTS]; + lookup[subscript] = new int[bins]; if(!smoothed[subscript]) - smoothed[subscript] = new float[HISTOGRAM_SLOTS]; + smoothed[subscript] = new float[bins]; if(!linear[subscript]) - linear[subscript] = new float[HISTOGRAM_SLOTS]; + linear[subscript] = new float[bins]; float *current_smooth = smoothed[subscript]; float *current_linear = linear[subscript]; // Make linear curve - for(i = 0; i < HISTOGRAM_SLOTS; i++) { - float input = (float)i / HISTOGRAM_SLOTS * FLOAT_RANGE + HIST_MIN_INPUT; + for( int i=0; iget_color_model()) - { - case BC_RGB888: - case BC_RGBA8888: - for(i = 0; i < 0x100; i++) - lookup[subscript][i] = - (int)(calculate_smooth((float)i / 0xff, subscript) * 0xff); - break; -// All other integer colormodels are converted to 16 bit RGB - default: - for(i = 0; i < 0x10000; i++) - lookup[subscript][i] = - (int)(calculate_smooth((float)i / 0xffff, subscript) * 0xffff); - break; + if( input ) { + int slots1 = slots-1; + for( int i=0; iplugin = plugin; this->server = server; - for(int i = 0; i < HISTOGRAM_MODES; i++) - accum[i] = new int[HISTOGRAM_SLOTS]; + int bins = plugin->slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100; + for( int i=0; ioperation == HistogramEngine::HISTOGRAM) - { + int bins = plugin->slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100; + int bins1 = bins-1; + int slots1 = -HISTOGRAM_MIN * (plugin->slots-1) / 100; + if( server->operation == HistogramEngine::HISTOGRAM ) { #define HISTOGRAM_HEAD(type) \ { \ - for(int i = pkg->start; i < pkg->end; i++) \ - { \ + for( int i=pkg->start; iend; ++i ) { \ type *row = (type*)data->get_rows()[i]; \ - for(int j = 0; j < w; j++) \ - { + for( int j=0; j> 8; */ \ - v = MAX(r, g); \ - v = MAX(v, b); \ - r += -HISTOGRAM_MIN * 0xffff / 100; \ - g += -HISTOGRAM_MIN * 0xffff / 100; \ - b += -HISTOGRAM_MIN * 0xffff / 100; \ - v += -HISTOGRAM_MIN * 0xffff / 100; \ - CLAMP(r, 0, HISTOGRAM_SLOTS-1); \ - CLAMP(g, 0, HISTOGRAM_SLOTS-1); \ - CLAMP(b, 0, HISTOGRAM_SLOTS-1); \ - CLAMP(v, 0, HISTOGRAM_SLOTS-1); \ - accum_r[r]++; \ - accum_g[g]++; \ - accum_b[b]++; \ - accum_v[v]++; \ + v = MAX(r, g); v = MAX(v, b); v += slots1; \ + r += slots1; g += slots1; b += slots1; \ + CLAMP(r, 0, bins1); ++accum_r[r]; \ + CLAMP(g, 0, bins1); ++accum_g[g]; \ + CLAMP(b, 0, bins1); ++accum_b[b]; \ + CLAMP(v, 0, bins1); ++accum_v[v]; \ row += components; \ } \ } \ @@ -628,99 +596,77 @@ void HistogramUnit::process_package(LoadPackage *package) int *accum_v = accum[HISTOGRAM_VALUE]; int r, g, b, y, u, v; - switch(data->get_color_model()) - { - case BC_RGB888: - HISTOGRAM_HEAD(unsigned char) - r = (row[0] << 8) | row[0]; - g = (row[1] << 8) | row[1]; - b = (row[2] << 8) | row[2]; - HISTOGRAM_TAIL(3) - break; - case BC_RGB_FLOAT: - HISTOGRAM_HEAD(float) - r = (int)(row[0] * 0xffff); - g = (int)(row[1] * 0xffff); - b = (int)(row[2] * 0xffff); - HISTOGRAM_TAIL(3) - break; - case BC_YUV888: - HISTOGRAM_HEAD(unsigned char) - y = (row[0] << 8) | row[0]; - u = (row[1] << 8) | row[1]; - v = (row[2] << 8) | row[2]; - YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); - HISTOGRAM_TAIL(3) - break; - case BC_RGBA8888: - HISTOGRAM_HEAD(unsigned char) - r = (row[0] << 8) | row[0]; - g = (row[1] << 8) | row[1]; - b = (row[2] << 8) | row[2]; - HISTOGRAM_TAIL(4) - break; - case BC_RGBA_FLOAT: - HISTOGRAM_HEAD(float) - r = (int)(row[0] * 0xffff); - g = (int)(row[1] * 0xffff); - b = (int)(row[2] * 0xffff); - HISTOGRAM_TAIL(4) - break; - case BC_YUVA8888: - HISTOGRAM_HEAD(unsigned char) - y = (row[0] << 8) | row[0]; - u = (row[1] << 8) | row[1]; - v = (row[2] << 8) | row[2]; - YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); - HISTOGRAM_TAIL(4) - break; - case BC_RGB161616: - HISTOGRAM_HEAD(uint16_t) - r = row[0]; - g = row[1]; - b = row[2]; - HISTOGRAM_TAIL(3) - break; - case BC_YUV161616: - HISTOGRAM_HEAD(uint16_t) - y = row[0]; - u = row[1]; - v = row[2]; - YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); - HISTOGRAM_TAIL(3) - break; - case BC_RGBA16161616: - HISTOGRAM_HEAD(uint16_t) - r = row[0]; - g = row[1]; - b = row[2]; - HISTOGRAM_TAIL(3) - break; - case BC_YUVA16161616: - HISTOGRAM_HEAD(uint16_t) - y = row[0]; - u = row[1]; - v = row[2]; - YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); - HISTOGRAM_TAIL(4) - break; + switch( data->get_color_model() ) { + case BC_RGB888: + HISTOGRAM_HEAD(unsigned char) + r = row[0]; g = row[1]; b = row[2]; + HISTOGRAM_TAIL(3) + break; + case BC_RGB_FLOAT: + HISTOGRAM_HEAD(float) + r = (int)(row[0] * 0xffff); + g = (int)(row[1] * 0xffff); + b = (int)(row[2] * 0xffff); + HISTOGRAM_TAIL(3) + break; + case BC_YUV888: + HISTOGRAM_HEAD(unsigned char) + y = row[0]; u = row[1]; v = row[2]; + YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v); + HISTOGRAM_TAIL(3) + break; + case BC_RGBA8888: + HISTOGRAM_HEAD(unsigned char) + r = row[0]; g = row[1]; b = row[2]; + HISTOGRAM_TAIL(4) + break; + case BC_RGBA_FLOAT: + HISTOGRAM_HEAD(float) + r = (int)(row[0] * 0xffff); + g = (int)(row[1] * 0xffff); + b = (int)(row[2] * 0xffff); + HISTOGRAM_TAIL(4) + break; + case BC_YUVA8888: + HISTOGRAM_HEAD(unsigned char) + y = row[0]; u = row[1]; v = row[2]; + YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v); + HISTOGRAM_TAIL(4) + break; + case BC_RGB161616: + HISTOGRAM_HEAD(uint16_t) + r = row[0]; g = row[1]; b = row[2]; + HISTOGRAM_TAIL(3) + break; + case BC_YUV161616: + HISTOGRAM_HEAD(uint16_t) + y = row[0]; u = row[1]; v = row[2]; + YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); + HISTOGRAM_TAIL(3) + break; + case BC_RGBA16161616: + HISTOGRAM_HEAD(uint16_t) + r = row[0]; g = row[1]; b = row[2]; + HISTOGRAM_TAIL(3) + break; + case BC_YUVA16161616: + HISTOGRAM_HEAD(uint16_t) + y = row[0]; u = row[1]; v = row[2]; + YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); + HISTOGRAM_TAIL(4) + break; } } else - if(server->operation == HistogramEngine::APPLY) - { - - + if( server->operation == HistogramEngine::APPLY ) { #define PROCESS(type, components) \ { \ - for(int i = pkg->start; i < pkg->end; i++) \ - { \ + for( int i=pkg->start; iend; ++i ) { \ type *row = (type*)input->get_rows()[i]; \ - for(int j = 0; j < w; j++) \ - { \ + for( int j=0; jconfig.split && ((j + i * w / h) < w) ) \ - continue; \ + continue; \ row[0] = lookup_r[row[0]]; \ row[1] = lookup_g[row[1]]; \ row[2] = lookup_b[row[2]]; \ @@ -731,49 +677,22 @@ void HistogramUnit::process_package(LoadPackage *package) #define PROCESS_YUV(type, components, max) \ { \ - for(int i = pkg->start; i < pkg->end; i++) \ - { \ + for( int i=pkg->start; iend; ++i ) { \ type *row = (type*)input->get_rows()[i]; \ - for(int j = 0; j < w; j++) \ - { \ + for( int j=0; jconfig.split && ((j + i * w / h) < w) ) \ - continue; \ -/* Convert to 16 bit RGB */ \ - if(max == 0xff) \ - { \ - y = (row[0] << 8) | row[0]; \ - u = (row[1] << 8) | row[1]; \ - v = (row[2] << 8) | row[2]; \ - } \ + continue; \ + y = row[0]; u = row[1]; v = row[2]; \ + if( max == 0xff ) \ + YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v); \ else \ - { \ - y = row[0]; \ - u = row[1]; \ - v = row[2]; \ - } \ - \ - YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); \ - \ -/* Look up in RGB domain */ \ - r = lookup_r[r]; \ - g = lookup_g[g]; \ - b = lookup_b[b]; \ - \ -/* Convert to 16 bit YUV */ \ - YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v); \ - \ - if(max == 0xff) \ - { \ - row[0] = y >> 8; \ - row[1] = u >> 8; \ - row[2] = v >> 8; \ - } \ + YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); \ + r = lookup_r[r]; g = lookup_g[g]; b = lookup_b[b]; \ + if( max == 0xff ) \ + YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v); \ else \ - { \ - row[0] = y; \ - row[1] = u; \ - row[2] = v; \ - } \ + YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v); \ + row[0] = y; row[1] = u; row[2] = v; \ row += components; \ } \ } \ @@ -781,25 +700,16 @@ void HistogramUnit::process_package(LoadPackage *package) #define PROCESS_FLOAT(components) \ { \ - for(int i = pkg->start; i < pkg->end; i++) \ - { \ + for( int i=pkg->start; iend; ++i ) { \ float *row = (float*)input->get_rows()[i]; \ - for(int j = 0; j < w; j++) \ - { \ + for( int j=0; jconfig.split && ((j + i * w / h) < w) ) \ - continue; \ - float r = row[0]; \ - float g = row[1]; \ - float b = row[2]; \ - \ + continue; \ + float r = row[0], g = row[1], b = row[2]; \ r = plugin->calculate_smooth(r, HISTOGRAM_RED); \ g = plugin->calculate_smooth(g, HISTOGRAM_GREEN); \ b = plugin->calculate_smooth(b, HISTOGRAM_BLUE); \ - \ - row[0] = r; \ - row[1] = g; \ - row[2] = b; \ - \ + row[0] = r; row[1] = g; row[2] = b; \ row += components; \ } \ } \ @@ -813,50 +723,44 @@ void HistogramUnit::process_package(LoadPackage *package) int *lookup_g = plugin->lookup[1]; int *lookup_b = plugin->lookup[2]; int r, g, b, y, u, v; - switch(input->get_color_model()) - { - case BC_RGB888: - PROCESS(unsigned char, 3) - break; - case BC_RGB_FLOAT: - PROCESS_FLOAT(3); - break; - case BC_RGBA8888: - PROCESS(unsigned char, 4) - break; - case BC_RGBA_FLOAT: - PROCESS_FLOAT(4); - break; - case BC_RGB161616: - PROCESS(uint16_t, 3) - break; - case BC_RGBA16161616: - PROCESS(uint16_t, 4) - break; - case BC_YUV888: - PROCESS_YUV(unsigned char, 3, 0xff) - break; - case BC_YUVA8888: - PROCESS_YUV(unsigned char, 4, 0xff) - break; - case BC_YUV161616: - PROCESS_YUV(uint16_t, 3, 0xffff) - break; - case BC_YUVA16161616: - PROCESS_YUV(uint16_t, 4, 0xffff) - break; + switch( input->get_color_model() ) { + case BC_RGB888: + PROCESS(unsigned char, 3) + break; + case BC_RGB_FLOAT: + PROCESS_FLOAT(3); + break; + case BC_RGBA8888: + PROCESS(unsigned char, 4) + break; + case BC_RGBA_FLOAT: + PROCESS_FLOAT(4); + break; + case BC_RGB161616: + PROCESS(uint16_t, 3) + break; + case BC_RGBA16161616: + PROCESS(uint16_t, 4) + break; + case BC_YUV888: + PROCESS_YUV(unsigned char, 3, 0xff) + break; + case BC_YUVA8888: + PROCESS_YUV(unsigned char, 4, 0xff) + break; + case BC_YUV161616: + PROCESS_YUV(uint16_t, 3, 0xffff) + break; + case BC_YUVA16161616: + PROCESS_YUV(uint16_t, 4, 0xffff) + break; } } } - - - - HistogramEngine::HistogramEngine(HistogramMain *plugin, - int total_clients, - int total_packages) + int total_clients, int total_packages) : LoadServer(total_clients, total_packages) { this->plugin = plugin; @@ -864,26 +768,19 @@ HistogramEngine::HistogramEngine(HistogramMain *plugin, void HistogramEngine::init_packages() { - switch(operation) { - case HISTOGRAM: - total_size = data->get_h(); - break; - case APPLY: - total_size = data->get_h(); - break; - } - - for(int i = 0; i < get_total_packages(); i++) { + total_size = data->get_h(); + for( int i=0,start=0,n=get_total_packages(); istart = total_size * i / get_total_packages(); - package->end = total_size * (i + 1) / get_total_packages(); + package->start = start; + package->end = start = (total_size * ++i)/ n; } + int bins = plugin->slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100; // Initialize clients here in case some don't get run. - for(int i = 0; i < get_total_clients(); i++) { + for( int i=0; iaccum[i], sizeof(int) * HISTOGRAM_SLOTS); + for( int i=0; iaccum[i], sizeof(int)*bins); } } diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogram.h b/cinelerra-5.1/plugins/histogram_bezier/bistogram.h index 2a3849d5..ae933b06 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogram.h +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogram.h @@ -44,6 +44,7 @@ class HistogramMain : public PluginVClient public: HistogramMain(PluginServer *server); ~HistogramMain(); + void reset(); int process_realtime(VFrame *input_ptr, VFrame *output_ptr); int is_realtime(); @@ -78,6 +79,8 @@ public: int current_point; // Current channel being viewed int mode; +// total histogram bins + int slots; int dragging_point; int point_x_offset; int point_y_offset; diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogram.inc b/cinelerra-5.1/plugins/histogram_bezier/bistogram.inc index d75b032a..835772ae 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogram.inc +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogram.inc @@ -34,8 +34,7 @@ #define HISTOGRAM_VALUE 3 // Number of divisions in histogram. -// 65536 + min and max range to speed up the tabulation -#define HISTOGRAM_SLOTS 0x13333 +// slots = (256 for 8bit or 65536) + min and max range to speed up the tabulation #define FLOAT_RANGE 1.2 // Minimum value in percentage #define HISTOGRAM_MIN -10 diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogramconfig.C b/cinelerra-5.1/plugins/histogram_bezier/bistogramconfig.C index 88c4911d..368cce72 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogramconfig.C +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogramconfig.C @@ -26,11 +26,14 @@ #include - - HistogramPoint::HistogramPoint() : ListItem() { + x = 0; y = 0; + xoffset_left = -0.05; + xoffset_right = 0.05; + gradient = 1.0; + } HistogramPoint::~HistogramPoint() @@ -39,15 +42,35 @@ HistogramPoint::~HistogramPoint() int HistogramPoint::equivalent(HistogramPoint *src) { - return EQUIV(x, src->x) && EQUIV(y, src->y) && EQUIV(gradient, src->gradient); + return EQUIV(x, src->x) && EQUIV(y, src->y) && + EQUIV(xoffset_left, src->xoffset_left) && + EQUIV(xoffset_right, src->xoffset_right) && + EQUIV(gradient, src->gradient); } +void HistogramPoint::copy_from(HistogramPoint *that) +{ + x = that->x; y = that->y; + xoffset_left = that->xoffset_left; + xoffset_right = that->xoffset_right; + gradient = that->gradient; +} HistogramPoints::HistogramPoints() : List() { + clear(); +} + +HistogramPoints::~HistogramPoints() +{ +} + +void HistogramPoints::clear() +{ + while( last ) delete last; insert(0.0,0.0); first->gradient = 1.0; first->xoffset_left = 0.0; @@ -56,11 +79,6 @@ HistogramPoints::HistogramPoints() last->gradient = 1.0; last->xoffset_left = -0.05; last->xoffset_right = 0.0; - -} - -HistogramPoints::~HistogramPoints() -{ } HistogramPoint* HistogramPoints::insert(float x, float y) @@ -68,40 +86,27 @@ HistogramPoint* HistogramPoints::insert(float x, float y) HistogramPoint *current = first; // Get existing point after new point - while(current) - { - if(current->x > x) - break; - else - current = NEXT; + while( current ) { + if( current->x > x ) break; + current = NEXT; } // Insert new point before current point HistogramPoint *new_point = new HistogramPoint; - if(current) - { + if( current ) insert_before(current, new_point); - } else -// Append new point to list - { append(new_point); - } new_point->x = x; new_point->y = y; - new_point->xoffset_left = -0.05; - new_point->xoffset_right = 0.05; - - return new_point; } void HistogramPoints::boundaries() { HistogramPoint *current = first; - while(current) - { + while( current ) { CLAMP(current->x, 0.0, 1.0); CLAMP(current->y, 0.0, 1.0); current = NEXT; @@ -112,14 +117,13 @@ int HistogramPoints::equivalent(HistogramPoints *src) { HistogramPoint *current_this = first; HistogramPoint *current_src = src->first; - while(current_this && current_src) - { + while( current_this && current_src ) { if(!current_this->equivalent(current_src)) return 0; current_this = current_this->next; current_src = current_src->next; } - return !current_this ^ !current_src ? 0 : 1; + return current_this || current_src ? 0 : 1; } void HistogramPoints::copy_from(HistogramPoints *src) @@ -127,48 +131,62 @@ void HistogramPoints::copy_from(HistogramPoints *src) while(last) delete last; HistogramPoint *current = src->first; - while(current) - { + while( current ) { HistogramPoint *new_point = new HistogramPoint; - new_point->x = current->x; - new_point->y = current->y; + new_point->copy_from(current); append(new_point); current = NEXT; } } -void HistogramPoints::interpolate(HistogramPoints *prev, - HistogramPoints *next, - double prev_scale, - double next_scale) +int HistogramPoints::cmprx(HistogramPoint *ap, HistogramPoint *bp) +{ + return ap->x < bp->x ? -1 : ap->x == bp->x ? 0 : 1; +} + +void HistogramPoints::interpolate(HistogramPoints *prev, HistogramPoints *next, + double prev_scale, double next_scale) { - HistogramPoint *current = first; HistogramPoint *current_prev = prev->first; HistogramPoint *current_next = next->first; - while(current && current_prev && current_next) - { - current->x = current_prev->x * prev_scale + - current_next->x * next_scale; - current->y = current_prev->y * prev_scale + - current_next->y * next_scale; - current = NEXT; - current_prev = current_prev->next; - current_next = current_next->next; + HistogramPoint *current = first; + while( current_prev || current_next ) { + if( !current ) { + current = new HistogramPoint; + append(current); + } + if( !current_next ) { + current->copy_from(current_prev); + current_prev = current_prev->next; + } + else if( !current_prev ) { + current->copy_from(current_next); + current_next = current_next->next; + } + else { + current->x = current_prev->x * prev_scale + + current_next->x * next_scale; + current->y = current_prev->y * prev_scale + + current_next->y * next_scale; + current->gradient = current_prev->gradient * prev_scale + + current_next->gradient * next_scale; + current->xoffset_left = current_prev->xoffset_left * prev_scale + + current_next->xoffset_left * next_scale; + current->xoffset_right = current_prev->xoffset_right * prev_scale + + current_next->xoffset_right * next_scale; + current_prev = current_prev->next; + current_next = current_next->next; + } + current = current->next; } -} - - - - - - - - - - - + while( current ) { + HistogramPoint *next_point = current->next; + delete current; current = next_point; + } + sort(cmprx); +} HistogramConfig::HistogramConfig() @@ -179,16 +197,12 @@ HistogramConfig::HistogramConfig() void HistogramConfig::reset(int do_mode) { reset_points(); - - - for(int i = 0; i < HISTOGRAM_MODES; i++) - { + for( int i = 0; i < HISTOGRAM_MODES; i++ ) { output_min[i] = 0.0; output_max[i] = 1.0; } - if(do_mode) - { + if( do_mode ) { automatic = 0; threshold = 1.0; split = 0; @@ -198,21 +212,14 @@ void HistogramConfig::reset(int do_mode) void HistogramConfig::reset_points() { - for(int i = 0; i < HISTOGRAM_MODES; i++) - { - while(points[i].last) delete points[i].last; - points[i].insert(0.0,0.0); - points[i].last->gradient = 1.0; - points[i].insert(1.0,1.0); - points[i].last->gradient = 1.0; - } + for( int i=0; ipoints[j]; HistogramPoint *current = points->first; - while(current) - { - printf("%f,%f ", current->x, current->y); + while( current ) { + printf("%f,%f (@%f l%f,r%f)\n", current->x, current->y, + current->gradient, current->xoffset_left, current->xoffset_right); fflush(stdout); current = NEXT; } - printf("\n"); } } - - diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogramconfig.h b/cinelerra-5.1/plugins/histogram_bezier/bistogramconfig.h index bcfb9848..c93aa55c 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogramconfig.h +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogramconfig.h @@ -35,6 +35,7 @@ public: ~HistogramPoint(); int equivalent(HistogramPoint *src); + void copy_from(HistogramPoint *that); float x, y; float gradient; float xoffset_left; @@ -50,13 +51,13 @@ public: // Insert new point HistogramPoint* insert(float x, float y); + void clear(); int equivalent(HistogramPoints *src); void boundaries(); void copy_from(HistogramPoints *src); - void interpolate(HistogramPoints *prev, - HistogramPoints *next, - double prev_scale, - double next_scale); + static int cmprx(HistogramPoint *ap, HistogramPoint *bp); + void interpolate(HistogramPoints *prev, HistogramPoints *next, + double prev_scale, double next_scale); }; class HistogramConfig diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogramwindow.C b/cinelerra-5.1/plugins/histogram_bezier/bistogramwindow.C index 8aa9c49e..8d23ff4a 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogramwindow.C +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogramwindow.C @@ -62,55 +62,35 @@ void HistogramWindow::create_objects() max_picon = create_pixmap(&max_picon_image); mid_picon = create_pixmap(&mid_picon_image); min_picon = create_pixmap(&min_picon_image); - add_subwindow(mode_v = new HistogramMode(plugin, - x, - y, - HISTOGRAM_VALUE, - _("Value"))); - x += 70; - add_subwindow(mode_r = new HistogramMode(plugin, - x, - y, - HISTOGRAM_RED, - _("Red"))); - x += 70; - add_subwindow(mode_g = new HistogramMode(plugin, - x, - y, - HISTOGRAM_GREEN, - _("Green"))); - x += 70; - add_subwindow(mode_b = new HistogramMode(plugin, - x, - y, - HISTOGRAM_BLUE, - _("Blue"))); -// x += 70; -// add_subwindow(mode_a = new HistogramMode(plugin, -// x, -// y, -// HISTOGRAM_ALPHA, -// _("Alpha"))); + add_subwindow(mode_v = new HistogramMode(plugin, x, y, + HISTOGRAM_VALUE, _("Value"))); + x += 80; + add_subwindow(mode_r = new HistogramMode(plugin, x, y, + HISTOGRAM_RED, _("Red"))); + x += 80; + add_subwindow(mode_g = new HistogramMode(plugin, x, y, + HISTOGRAM_GREEN, _("Green"))); + x += 80; + add_subwindow(mode_b = new HistogramMode(plugin, x, y, + HISTOGRAM_BLUE, _("Blue"))); +// x += 80; +// add_subwindow(mode_a = new HistogramMode(plugin, x, y, +// HISTOGRAM_ALPHA, _("Alpha"))); + + x = get_w() - HistogramClear::calculate_w(this, _("Clear")) - 15; + add_subwindow(clear = new HistogramClear(plugin, x, y, _("Clear"))); x = x1; y += 30; add_subwindow(title = new BC_Title(x, y, _("Input X:"))); x += title->get_w() + 10; - input_x = new HistogramInputText(plugin, - this, - x, - y, - 1); + input_x = new HistogramInputText(plugin, this, x, y, 1); input_x->create_objects(); x += input_x->get_w() + 10; add_subwindow(title = new BC_Title(x, y, _("Input Y:"))); x += title->get_w() + 10; - input_y = new HistogramInputText(plugin, - this, - x, - y, - 0); + input_y = new HistogramInputText(plugin, this, x, y, 0); input_y->create_objects(); y += 30; @@ -122,78 +102,48 @@ void HistogramWindow::create_objects() title2_x = x + (int)(canvas_w * -HIST_MIN_INPUT / FLOAT_RANGE); title3_x = x + (int)(canvas_w * (1.0 - HIST_MIN_INPUT) / FLOAT_RANGE); title4_x = x + (int)(canvas_w); - add_subwindow(canvas = new HistogramCanvas(plugin, - this, - x, - y, - canvas_w, - canvas_h)); + add_subwindow(canvas = new HistogramCanvas(plugin, this, + x, y, canvas_w, canvas_h)); draw_canvas_overlay(); canvas->flash(); y += canvas->get_h() + 1; - add_subwindow(new BC_Title(title1_x, - y, - "-10%")); - add_subwindow(new BC_Title(title2_x, - y, - "0%")); - add_subwindow(new BC_Title(title3_x - get_text_width(MEDIUMFONT, "100"), - y, - "100%")); - add_subwindow(new BC_Title(title4_x - get_text_width(MEDIUMFONT, "110"), - y, - "110%")); + add_subwindow(new BC_Title(title1_x, y, "-10%")); + add_subwindow(new BC_Title(title2_x, y, "0%")); + add_subwindow(new BC_Title(title3_x - get_text_width(MEDIUMFONT, "100"), y, "100%")); + add_subwindow(new BC_Title(title4_x - get_text_width(MEDIUMFONT, "110"), y, "110%")); y += 20; add_subwindow(title = new BC_Title(x, y, _("Output min:"))); x += title->get_w() + 10; - output_min = new HistogramOutputText(plugin, - this, - x, - y, - &plugin->config.output_min[plugin->mode]); + output_min = new HistogramOutputText(plugin, this, + x, y, &plugin->config.output_min[plugin->mode]); output_min->create_objects(); x += output_min->get_w() + 10; add_subwindow(new BC_Title(x, y, _("Output Max:"))); x += title->get_w() + 10; - output_max = new HistogramOutputText(plugin, - this, - x, - y, - &plugin->config.output_max[plugin->mode]); + output_max = new HistogramOutputText(plugin, this, + x, y, &plugin->config.output_max[plugin->mode]); output_max->create_objects(); x = x1; y += 30; - add_subwindow(output = new HistogramSlider(plugin, - this, - x, - y, - get_w() - 20, - 30, - 0)); + add_subwindow(output = new HistogramSlider(plugin, this, + x, y, get_w() - 20, 30, 0)); output->update(); y += 40; - add_subwindow(automatic = new HistogramAuto(plugin, - x, - y)); + add_subwindow(automatic = new HistogramAuto(plugin, x, y)); x += 120; - add_subwindow(new HistogramReset(plugin, - x, - y)); + add_subwindow(new HistogramReset(plugin, x, y)); x += 100; add_subwindow(new BC_Title(x, y, _("Threshold:"))); x += 100; - threshold = new HistogramOutputText(plugin, - this, - x, - y, - &plugin->config.threshold); + threshold = new HistogramOutputText(plugin, this, + x, y, &plugin->config.threshold); threshold->create_objects(); x = x1; y += 40; @@ -208,18 +158,22 @@ void HistogramWindow::create_objects() show_window(); } +int HistogramWindow::delete_current_point() +{ + if( plugin->current_point < 0 ) return 0; + HistogramPoint *current = + plugin->config.points[plugin->mode].get_item_number(plugin->current_point); + delete current; + plugin->current_point = -1; + return 1; +} + int HistogramWindow::keypress_event() { int result = 0; - if(get_keypress() == BACKSPACE || - get_keypress() == DELETE) - { - if(plugin->current_point >= 0) - { - HistogramPoint *current = - plugin->config.points[plugin->mode].get_item_number(plugin->current_point); - delete current; - plugin->current_point = -1; + if( get_keypress() == BACKSPACE || + get_keypress() == DELETE ) { + if( delete_current_point() ) { update_input(); update_canvas(); plugin->send_configure_change(); @@ -234,9 +188,11 @@ void HistogramWindow::update(int do_input) automatic->update(plugin->config.automatic); threshold->update(plugin->config.threshold); update_mode(); - - if(do_input) update_input(); + split->set_value(plugin->config.split); + if( do_input ) update_input(); update_output(); + if( smoothModeChoser->set_mode(plugin->config.smoothMode) ) + update_canvas(); } void HistogramWindow::update_input() @@ -271,17 +227,12 @@ void HistogramWindow::draw_canvas_overlay() // Draw output line canvas->set_color(0xffff00); - for(int i = 0; i < canvas_w; i++) - { - float input = (float)i / - canvas_w * - FLOAT_RANGE + - HIST_MIN_INPUT; + for( int i=0; icalculate_smooth(input, plugin->mode); int y2 = canvas_h - (int)(output * canvas_h); - if(i > 0) - { + if( i > 0 ) { canvas->draw_line(i - 1, y1, i, y2); } y1 = y2; @@ -291,8 +242,7 @@ void HistogramWindow::draw_canvas_overlay() // Draw output points HistogramPoint *current = plugin->config.points[plugin->mode].first; int number = 0; - while(current) - { + while( current ) { canvas->set_color(0x00ff00); int x = (int)((current->x - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE); int y = (int)(canvas_h - current->y * canvas_h); @@ -307,7 +257,7 @@ void HistogramWindow::draw_canvas_overlay() //Draw gradients if (plugin->config.smoothMode > HISTOGRAM_LINEAR) { int x1,x2,y1,y2; - canvas->set_color(0x0000ff); + canvas->set_color(0xffffff); x2 = (int)((current->x + current->xoffset_right - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE); x1 = (int)((current->x + current->xoffset_left - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE); y2 = (int)(canvas_h - (current->y + current->xoffset_right * current->gradient) * canvas_h); @@ -316,7 +266,7 @@ void HistogramWindow::draw_canvas_overlay() x1 = x - (title3_x - title2_x)/20; y1 = y + (int)(current->gradient * (float)(canvas_h)/20.0); y2 = y - (int)(current->gradient * (float)(canvas_h)/20.0); -// int y2 = (int)(canvas_h - canvas_h * (current->y + current->gradient /10));*/ + int y2 = (int)(canvas_h - canvas_h * (current->y + current->gradient /10));*/ canvas->draw_line(x1,y1,x2,y2); canvas->draw_circle(x1 - BOX_SIZE / 4, y1 - BOX_SIZE / 4, BOX_SIZE/2, BOX_SIZE/2); @@ -330,54 +280,47 @@ void HistogramWindow::draw_canvas_overlay() // Draw 0 and 100% lines. canvas->set_color(0xff0000); - canvas->draw_line(title2_x - canvas->get_x(), - 0, - title2_x - canvas->get_x(), - canvas_h); - canvas->draw_line(title3_x - canvas->get_x(), - 0, - title3_x - canvas->get_x(), - canvas_h); + canvas->draw_line(title2_x - canvas->get_x(), 0, + title2_x - canvas->get_x(), canvas_h); + canvas->draw_line(title3_x - canvas->get_x(), 0, + title3_x - canvas->get_x(), canvas_h); } void HistogramWindow::update_canvas() { + int bins = plugin->slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100; int *accum = plugin->accum[plugin->mode]; - int accum_per_canvas_i = HISTOGRAM_SLOTS / canvas_w + 1; - float accum_per_canvas_f = (float)HISTOGRAM_SLOTS / canvas_w; int normalize = 0; int max = 0; - for(int i = 0; i < HISTOGRAM_SLOTS; i++) - { - if(accum && accum[i] > normalize) normalize = accum[i]; + if( accum ) { + for( int i=0; i normalize ) + normalize = accum[i]; } - if(normalize) - { - for(int i = 0; i < canvas_w; i++) - { - int accum_start = (int)(accum_per_canvas_f * i); - int accum_end = accum_start + accum_per_canvas_i; + if( normalize ) { + int accum_start = 0; + for( int i=0; iset_color(0xffffff); + canvas->set_color(0x333333); canvas->draw_line(i, 0, i, canvas_h - max); - canvas->set_color(0x000000); + canvas->set_color(0x848484); canvas->draw_line(i, canvas_h - max, i, canvas_h); + accum_start = accum_end; } } - else - { - canvas->set_color(0xffffff); + else { + canvas->set_color(0x333333); canvas->draw_box(0, 0, canvas_w, canvas_h); } @@ -387,23 +330,9 @@ void HistogramWindow::update_canvas() } - - - - - - -HistogramCanvas::HistogramCanvas(HistogramMain *plugin, - HistogramWindow *gui, - int x, - int y, - int w, - int h) - : BC_SubWindow(x, - y, - w, - h, - 0xffffff) +HistogramCanvas::HistogramCanvas(HistogramMain *plugin, HistogramWindow *gui, + int x, int y, int w, int h) + : BC_SubWindow(x, y, w, h, 0x333333) { this->plugin = plugin; this->gui = gui; @@ -412,27 +341,23 @@ HistogramCanvas::HistogramCanvas(HistogramMain *plugin, int HistogramCanvas::button_press_event() { int result = 0; - if(is_event_win() && cursor_inside()) - { - if(!plugin->dragging_point) - { + if( is_event_win() && cursor_inside() ) { + if( !plugin->dragging_point ) { HistogramPoint *new_point = 0; gui->deactivate(); // Search for existing point under cursor HistogramPoint *current = plugin->config.points[plugin->mode].first; plugin->current_point = -1; int dragID = 0; - while(current) - { + while( current ) { int x = (int)((current->x - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE); int y = (int)(gui->canvas_h - current->y * gui->canvas_h); /* Check for click on main point */ - if(get_cursor_x() >= x - BOX_SIZE / 2 && - get_cursor_y() >= y - BOX_SIZE / 2 && - get_cursor_x() < x + BOX_SIZE / 2 && - get_cursor_y() < y + BOX_SIZE / 2) - { + if( get_cursor_x() >= x - BOX_SIZE / 2 && + get_cursor_y() >= y - BOX_SIZE / 2 && + get_cursor_x() < x + BOX_SIZE / 2 && + get_cursor_y() < y + BOX_SIZE / 2 ) { plugin->current_point = plugin->config.points[plugin->mode].number_of(current); plugin->point_x_offset = get_cursor_x() - x; @@ -450,11 +375,10 @@ int HistogramCanvas::button_press_event() gui->canvas_h); /* Check for click on right handle */ - if(get_cursor_x() >= xright - BOX_SIZE / 2 && - get_cursor_y() >= yright - BOX_SIZE / 2 && - get_cursor_x() < xright + BOX_SIZE / 2 && - get_cursor_y() < yright + BOX_SIZE / 2) - { + if( get_cursor_x() >= xright - BOX_SIZE / 2 && + get_cursor_y() >= yright - BOX_SIZE / 2 && + get_cursor_x() < xright + BOX_SIZE / 2 && + get_cursor_y() < yright + BOX_SIZE / 2 ) { plugin->current_point = plugin->config.points[plugin->mode].number_of(current); plugin->point_x_offset = get_cursor_x() - xright; @@ -469,11 +393,10 @@ int HistogramCanvas::button_press_event() int yleft = (int)(gui->canvas_h - (current->y + current->xoffset_left * current->gradient) * gui->canvas_h); - if(get_cursor_x() >= xleft - BOX_SIZE / 2 && - get_cursor_y() >= yleft - BOX_SIZE / 2 && - get_cursor_x() < xleft + BOX_SIZE / 2 && - get_cursor_y() < yleft + BOX_SIZE / 2) - { + if( get_cursor_x() >= xleft - BOX_SIZE / 2 && + get_cursor_y() >= yleft - BOX_SIZE / 2 && + get_cursor_x() < xleft + BOX_SIZE / 2 && + get_cursor_y() < yleft + BOX_SIZE / 2 ) { plugin->current_point = plugin->config.points[plugin->mode].number_of(current); plugin->point_x_offset = get_cursor_x() - xleft; @@ -482,20 +405,13 @@ int HistogramCanvas::button_press_event() break; } - current = NEXT; } - if(plugin->current_point < 0) - { + if( plugin->current_point < 0 ) { // Create new point under cursor - float current_x = (float)get_cursor_x() * - FLOAT_RANGE / - get_w() + - HIST_MIN_INPUT; - float current_y = 1.0 - - (float)get_cursor_y() / - get_h(); + float current_x = (float)get_cursor_x() * FLOAT_RANGE / get_w() + HIST_MIN_INPUT; + float current_y = 1.0 - (float)get_cursor_y() / get_h(); new_point = plugin->config.points[plugin->mode].insert(current_x, current_y); plugin->current_point = @@ -509,10 +425,8 @@ int HistogramCanvas::button_press_event() HistogramPoint *current = plugin->config.points[plugin->mode].first; int done = 0; - while(current && !done) - { - if(current->x > current_x) - { + while( current && !done ) { + if( current->x > current_x ) { x2 = current->x; y2 = current->y; done = 1; @@ -523,10 +437,8 @@ int HistogramCanvas::button_press_event() current = plugin->config.points[plugin->mode].last; done = 0; - while(current && !done) - { - if(current->x <= current_x) - { + while( current && !done ) { + if( current->x <= current_x ) { x1 = current->x; y1 = current->y; done = 1; @@ -536,9 +448,13 @@ int HistogramCanvas::button_press_event() } new_point->gradient = (y2 - y1) / (x2 - x1); dragID = 1; - } - + else if( dragID == 1 && get_buttonpress() == RIGHT_BUTTON ) { + if( gui->delete_current_point() ) { + plugin->send_configure_change(); + dragID = 0; + } + } plugin->dragging_point = dragID; result = 1; @@ -546,8 +462,7 @@ int HistogramCanvas::button_press_event() plugin->config.boundaries(); gui->update_input(); gui->update_canvas(); - if(new_point) - { + if( new_point ) { plugin->send_configure_change(); } } @@ -557,39 +472,31 @@ int HistogramCanvas::button_press_event() int HistogramCanvas::cursor_motion_event() { - if(plugin->dragging_point) - { - HistogramPoint * current_point = plugin->config.points[plugin->mode].get_item_number(plugin->current_point); - - float current_x = - (float)(get_cursor_x() - plugin->point_x_offset) * - FLOAT_RANGE / - get_w() + - HIST_MIN_INPUT; - float current_y = 1.0 - - (float)(get_cursor_y() - plugin->point_y_offset) / - get_h(); - - switch(plugin->dragging_point) - { - case 1: /* Main point dragged */ + if( plugin->dragging_point ) { + HistogramPoints *mode_points = &plugin->config.points[plugin->mode]; + HistogramPoint *current_point = mode_points->get_item_number(plugin->current_point); + + float current_x = + (float)(get_cursor_x() - plugin->point_x_offset) * FLOAT_RANGE / get_w() + HIST_MIN_INPUT; + float current_y = 1.0 - (float)(get_cursor_y() - plugin->point_y_offset) / get_h(); + + switch( plugin->dragging_point ) { + case 1: /* Main point dragged */ current_point->x = current_x; current_point->y = current_y; break; - case 2: /* Right control point dragged */ - if (current_x - current_point->x > 0) - { - current_point->xoffset_right = current_x - current_point->x; - current_point->gradient = (current_y - current_point->y) / (current_x - current_point->x); - } - break; - case 3: /* Left control point dragged */ - if (current_x - current_point->x < 0) - { - current_point->xoffset_left = current_x - current_point->x; - current_point->gradient = (current_point->y - current_y) / (current_point->x - current_x); - } - break; + case 2: /* Right control point dragged */ + if( current_x - current_point->x > 0 ) { + current_point->xoffset_right = current_x - current_point->x; + current_point->gradient = (current_y - current_point->y) / (current_x - current_point->x); + } + break; + case 3: /* Left control point dragged */ + if( current_x - current_point->x < 0 ) { + current_point->xoffset_left = current_x - current_point->x; + current_point->gradient = (current_point->y - current_y) / (current_point->x - current_x); + } + break; } plugin->config.boundaries(); @@ -611,38 +518,30 @@ int HistogramCanvas::button_release_event() HistogramPoint *prev = PREVIOUS; HistogramPoint *next = NEXT; - if((prev && prev->x >= current->x) || - (next && next->x <= current->x)) - { + if( (prev && prev->x >= current->x) || + (next && next->x <= current->x) ) { delete current; plugin->current_point = -1; plugin->config.boundaries(); gui->update_input(); gui->update_canvas(); - plugin->send_configure_change(); } + plugin->send_configure_change(); plugin->dragging_point = 0; } return 0; } - - - - - -HistogramReset::HistogramReset(HistogramMain *plugin, - int x, - int y) +HistogramReset::HistogramReset(HistogramMain *plugin, int x, int y) : BC_GenericButton(x, y, _("Reset")) { this->plugin = plugin; } int HistogramReset::handle_event() { - plugin->config.reset(0); + plugin->config.reset(1); HistogramWindow *window = (HistogramWindow *)plugin->thread->window; window->update(1); window->update_canvas(); @@ -651,20 +550,8 @@ int HistogramReset::handle_event() } - - - - - - - -HistogramSlider::HistogramSlider(HistogramMain *plugin, - HistogramWindow *gui, - int x, - int y, - int w, - int h, - int is_input) +HistogramSlider::HistogramSlider(HistogramMain *plugin, HistogramWindow *gui, + int x, int y, int w, int h, int is_input) : BC_SubWindow(x, y, w, h) { this->plugin = plugin; @@ -680,34 +567,29 @@ int HistogramSlider::input_to_pixel(float input) int HistogramSlider::button_press_event() { - if(is_event_win() && cursor_inside()) - { + if( is_event_win() && cursor_inside() ) { // int w = get_w(); int h = get_h(); int half_h = get_h() / 2; gui->deactivate(); - if(operation == NONE) - { + if( operation == NONE ) { int x1 = input_to_pixel(plugin->config.output_min[plugin->mode]) - gui->mid_picon->get_w() / 2; int x2 = x1 + gui->mid_picon->get_w(); - if(get_cursor_x() >= x1 && get_cursor_x() < x2 && - get_cursor_y() >= half_h && get_cursor_y() < h) - { + if( get_cursor_x() >= x1 && get_cursor_x() < x2 && + get_cursor_y() >= half_h && get_cursor_y() < h ) { operation = DRAG_MIN_OUTPUT; } } - if(operation == NONE) - { + if( operation == NONE ) { int x1 = input_to_pixel(plugin->config.output_max[plugin->mode]) - gui->mid_picon->get_w() / 2; int x2 = x1 + gui->mid_picon->get_w(); - if(get_cursor_x() >= x1 && get_cursor_x() < x2 && - get_cursor_y() >= half_h && get_cursor_y() < h) - { + if( get_cursor_x() >= x1 && get_cursor_x() < x2 && + get_cursor_y() >= half_h && get_cursor_y() < h ) { operation = DRAG_MAX_OUTPUT; } } @@ -718,70 +600,54 @@ int HistogramSlider::button_press_event() int HistogramSlider::button_release_event() { - if(operation != NONE) - { - operation = NONE; - return 1; - } - return 0; + if( operation == NONE ) return 0; + operation = NONE; + return 1; } int HistogramSlider::cursor_motion_event() { - if(operation != NONE) - { - float value = (float)get_cursor_x() / get_w() * FLOAT_RANGE + HIST_MIN_INPUT; - CLAMP(value, HIST_MIN_INPUT, HIST_MAX_INPUT); - - switch(operation) - { - case DRAG_MIN_OUTPUT: - value = MIN(plugin->config.output_max[plugin->mode], value); - plugin->config.output_min[plugin->mode] = value; - break; - case DRAG_MAX_OUTPUT: - value = MAX(plugin->config.output_min[plugin->mode], value); - plugin->config.output_max[plugin->mode] = value; - break; - } + if( operation == NONE ) return 0; - plugin->config.boundaries(); - gui->update_output(); + float value = (float)get_cursor_x() / get_w() * FLOAT_RANGE + HIST_MIN_INPUT; + CLAMP(value, HIST_MIN_INPUT, HIST_MAX_INPUT); - plugin->send_configure_change(); - return 1; + switch( operation ) { + case DRAG_MIN_OUTPUT: + value = MIN(plugin->config.output_max[plugin->mode], value); + plugin->config.output_min[plugin->mode] = value; + break; + case DRAG_MAX_OUTPUT: + value = MAX(plugin->config.output_min[plugin->mode], value); + plugin->config.output_max[plugin->mode] = value; + break; } - return 0; + + plugin->config.boundaries(); + gui->update_output(); + + plugin->send_configure_change(); + return 1; } void HistogramSlider::update() { - int w = get_w(); - int h = get_h(); + int w = get_w(), h = get_h(); int half_h = get_h() / 2; // int quarter_h = get_h() / 4; int mode = plugin->mode; - int r = 0xff; - int g = 0xff; - int b = 0xff; + int r = 0, g = 0, b = 0; clear_box(0, 0, w, h); - switch(mode) - { - case HISTOGRAM_RED: - g = b = 0x00; - break; - case HISTOGRAM_GREEN: - r = b = 0x00; - break; - case HISTOGRAM_BLUE: - r = g = 0x00; - break; + switch( mode ) { + case HISTOGRAM_RED: r = 0xff; break; + case HISTOGRAM_GREEN: g = 0xff; break; + case HISTOGRAM_BLUE: b = 0xff; break; + case HISTOGRAM_VALUE: r = g = b = 0xff; break; } - for(int i = 0; i < w; i++) - { + for( int i=0; iconfig.output_min[plugin->mode]; - max = plugin->config.output_max[plugin->mode]; - + float min = plugin->config.output_min[plugin->mode]; draw_pixmap(gui->min_picon, input_to_pixel(min) - gui->min_picon->get_w() / 2, half_h + 1); + float max = plugin->config.output_max[plugin->mode]; draw_pixmap(gui->max_picon, input_to_pixel(max) - gui->max_picon->get_w() / 2, half_h + 1); @@ -807,16 +670,7 @@ void HistogramSlider::update() } - - - - - - - -HistogramAuto::HistogramAuto(HistogramMain *plugin, - int x, - int y) +HistogramAuto::HistogramAuto(HistogramMain *plugin, int x, int y) : BC_CheckBox(x, y, plugin->config.automatic, _("Automatic")) { this->plugin = plugin; @@ -830,11 +684,7 @@ int HistogramAuto::handle_event() } - - -HistogramSplit::HistogramSplit(HistogramMain *plugin, - int x, - int y) +HistogramSplit::HistogramSplit(HistogramMain *plugin, int x, int y) : BC_CheckBox(x, y, plugin->config.split, _("Split picture")) { this->plugin = plugin; @@ -848,13 +698,8 @@ int HistogramSplit::handle_event() } - - -HistogramMode::HistogramMode(HistogramMain *plugin, - int x, - int y, - int value, - char *text) +HistogramMode::HistogramMode(HistogramMain *plugin, int x, int y, + int value, const char *text) : BC_Radial(x, y, plugin->mode == value, text) { this->plugin = plugin; @@ -865,10 +710,9 @@ int HistogramMode::handle_event() plugin->mode = value; plugin->current_point= -1; HistogramWindow *window = (HistogramWindow *)plugin->thread->window; - window->update_canvas(); window->update_mode(); - window->update_input(); window->update_canvas(); + window->update_input(); window->update_output(); window->output->update(); // plugin->send_configure_change(); @@ -876,25 +720,31 @@ int HistogramMode::handle_event() } +HistogramClear::HistogramClear(HistogramMain *plugin, int x, int y, const char *text) + : BC_GenericButton(x, y, text) +{ + this->plugin = plugin; +} - - - - +int HistogramClear::handle_event() +{ + HistogramPoints *mode_points = &plugin->config.points[plugin->mode]; + mode_points->clear(); + plugin->config.output_min[plugin->mode] = 0.0; + plugin->config.output_max[plugin->mode] = 1.0; + HistogramWindow *window = (HistogramWindow *)plugin->thread->window; + window->update(1); + window->update_canvas(); + plugin->send_configure_change(); + return 1; +} HistogramOutputText::HistogramOutputText(HistogramMain *plugin, - HistogramWindow *gui, - int x, - int y, - float *output) - : BC_TumbleTextBox(gui, - output ? (float)*output : 0.0, - (float)HIST_MIN_INPUT, - (float)HIST_MAX_INPUT, - x, - y, - 60) + HistogramWindow *gui, int x, int y, float *output) + : BC_TumbleTextBox(gui, output ? (float)*output : 0.0, + (float)HIST_MIN_INPUT, (float)HIST_MAX_INPUT, + x, y, 60) { this->plugin = plugin; this->output = output; @@ -902,11 +752,9 @@ HistogramOutputText::HistogramOutputText(HistogramMain *plugin, set_increment(PRECISION); } - int HistogramOutputText::handle_event() { - if(output) - { + if( output ) { *output = atof(get_text()); } @@ -917,24 +765,11 @@ int HistogramOutputText::handle_event() } - - - - - - HistogramInputText::HistogramInputText(HistogramMain *plugin, - HistogramWindow *gui, - int x, - int y, - int do_x) - : BC_TumbleTextBox(gui, - 0.0, - (float)HIST_MIN_INPUT, - (float)HIST_MAX_INPUT, - x, - y, - 60) + HistogramWindow *gui, int x, int y, int do_x) + : BC_TumbleTextBox(gui, 0.0, + (float)HIST_MIN_INPUT, (float)HIST_MAX_INPUT, + x, y, 60) { this->do_x = do_x; this->plugin = plugin; @@ -943,19 +778,15 @@ HistogramInputText::HistogramInputText(HistogramMain *plugin, set_increment(PRECISION); } - int HistogramInputText::handle_event() { - if(plugin->current_point >= 0 && - plugin->current_point < plugin->config.points[plugin->mode].total()) - { - HistogramPoint *point = - plugin->config.points[plugin->mode].get_item_number( - plugin->current_point); + if( plugin->current_point >= 0 && + plugin->current_point < plugin->config.points[plugin->mode].total() ) { + HistogramPoints *mode_points = &plugin->config.points[plugin->mode]; + HistogramPoint *point = mode_points->get_item_number(plugin->current_point); - if(point) - { - if(do_x) + if( point ) { + if( do_x ) point->x = atof(get_text()); else point->y = atof(get_text()); @@ -973,28 +804,22 @@ int HistogramInputText::handle_event() void HistogramInputText::update() { - if(plugin->current_point >= 0 && - plugin->current_point < plugin->config.points[plugin->mode].total()) - { - HistogramPoint *point = + if( plugin->current_point >= 0 && + plugin->current_point < plugin->config.points[plugin->mode].total() ) { + HistogramPoints *mode_points = &plugin->config.points[plugin->mode]; + HistogramPoint *point = mode_points->get_item_number(plugin->current_point); - plugin->config.points[plugin->mode].get_item_number( - plugin->current_point); - - if(point) - { - if(do_x) + if( point ) { + if( do_x ) BC_TumbleTextBox::update(point->x); else BC_TumbleTextBox::update(point->y); } - else - { + else { BC_TumbleTextBox::update((float)0.0); } } - else - { + else { BC_TumbleTextBox::update((float)0.0); } @@ -1002,9 +827,7 @@ void HistogramInputText::update() HistogramSmoothMode::HistogramSmoothMode(HistogramMain*plugin, - HistogramWindow *gui, - int x, - int y) + HistogramWindow *gui, int x, int y) : BC_PopupMenu(x, y, 120, to_text(plugin->config.smoothMode), 1) { this->plugin = plugin; @@ -1019,47 +842,41 @@ void HistogramSmoothMode::create_objects() char* HistogramSmoothMode::to_text(int mode) { - switch(mode) - { - case HISTOGRAM_LINEAR: - return _("Linear"); - case HISTOGRAM_POLYNOMINAL: - return _("Polynominal"); - case HISTOGRAM_BEZIER: - return _("Bezier"); + switch( mode ) { + case HISTOGRAM_LINEAR: return _("Linear"); + case HISTOGRAM_POLYNOMINAL: return _("Polynominal"); + case HISTOGRAM_BEZIER: return _("Bezier"); } return _("None"); } +int HistogramSmoothMode::set_mode(int mode) +{ + const char *tp = to_text(mode); + if( strcmp(tp, get_text()) ) { + set_text(tp); + return 1; + } + return 0; +} + int HistogramSmoothMode::from_text(char *text) { - if(!strcmp(text, to_text(HISTOGRAM_LINEAR))) - return HISTOGRAM_LINEAR; - if(!strcmp(text, to_text(HISTOGRAM_POLYNOMINAL))) - return HISTOGRAM_POLYNOMINAL; - if(!strcmp(text, to_text(HISTOGRAM_BEZIER))) - return HISTOGRAM_BEZIER; + if( !strcmp(text, to_text(HISTOGRAM_LINEAR)) ) return HISTOGRAM_LINEAR; + if( !strcmp(text, to_text(HISTOGRAM_POLYNOMINAL)) ) return HISTOGRAM_POLYNOMINAL; + if( !strcmp(text, to_text(HISTOGRAM_BEZIER)) ) return HISTOGRAM_BEZIER; return HISTOGRAM_LINEAR; } +int HistogramSmoothMode::get_mode() +{ + return from_text(get_text()); +} int HistogramSmoothMode::handle_event() { - plugin->config.smoothMode = from_text(get_text()); + plugin->config.smoothMode = get_mode(); gui->update_canvas(); plugin->send_configure_change(); return 1; } - - - - - - - - - - - - - diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogramwindow.h b/cinelerra-5.1/plugins/histogram_bezier/bistogramwindow.h index 9a7bab4e..5051607f 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogramwindow.h +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogramwindow.h @@ -37,6 +37,8 @@ public: int x, int y); void create_objects(); + int set_mode(int mode); + int get_mode(); static char* to_text(int shape); static int from_text(char *text); int handle_event(); @@ -97,16 +99,23 @@ public: class HistogramMode : public BC_Radial { public: - HistogramMode(HistogramMain *plugin, - int x, - int y, - int value, - char *text); + HistogramMode(HistogramMain *plugin, int x, int y, + int value, const char *text); int handle_event(); + HistogramMain *plugin; int value; }; +class HistogramClear : public BC_GenericButton +{ +public: + HistogramClear(HistogramMain *plugin, int x, int y, const char *text); + int handle_event(); + + HistogramMain *plugin; +}; + class HistogramReset : public BC_GenericButton { public: @@ -177,6 +186,7 @@ public: void draw_canvas_overlay(); void update_input(); void update_output(); + int delete_current_point(); int keypress_event(); HistogramSlider *output; @@ -184,6 +194,7 @@ public: HistogramSplit *split; HistogramSmoothMode *smoothModeChoser; HistogramMode *mode_v, *mode_r, *mode_g, *mode_b /*, *mode_a */; + HistogramClear *clear; HistogramOutputText *output_min; HistogramOutputText *output_max; HistogramOutputText *threshold; diff --git a/cinelerra-5.1/po/de.po b/cinelerra-5.1/po/de.po index ea8ff8e8..9f16c561 100644 --- a/cinelerra-5.1/po/de.po +++ b/cinelerra-5.1/po/de.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: cinelerra 5.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-10-23 19:01+0200\n" -"PO-Revision-Date: 2018-10-23 20:07+0200\n" +"PO-Revision-Date: 2018-10-27 13:36+0200\n" "Last-Translator: Olaf \n" "Language-Team: Language-Team \n" "Language: de\n" @@ -12209,6 +12209,8 @@ msgstr "Momentäre Hinweise" msgid "Ctrl or Shift to select multiple notes." msgstr "Strg oder Umschalt, um mehrere Noten auswählen." +# Themen-Namen dürfen derzeit nicht übersetzt werden, +# zudem handelt es sich um Eigennamen. #: plugins/theme_blond/blondtheme.C:71 msgid "Blond" msgstr "Blond" @@ -12219,11 +12221,11 @@ msgstr "Blond-cv" #: plugins/theme_blue_dot/bluedottheme.C:73 msgid "Blue Dot" -msgstr "Blauer Punkt" +msgstr "Blue Dot" #: plugins/theme_bright/brighttheme.C:69 msgid "Bright" -msgstr "Hell" +msgstr "Bright" #: plugins/theme_hulk/hulktheme.C:72 msgid "Hulk" @@ -12245,7 +12247,7 @@ msgstr "S.U.V." #: plugins/theme_unflat/unflattheme.C:66 msgid "UnFlat" -msgstr "UnEben" +msgstr "UnFlat" #: plugins/threshold/thresholdwindow.C:310 msgid "Low Color" -- 2.26.2