From ca56050ec5b51deb91ebdae1046de6e9165ba5cb Mon Sep 17 00:00:00 2001 From: Stefan Jahn Date: Sat, 26 Nov 2022 20:48:36 +0100 Subject: [PATCH] Logarithmic histogram for testing... --- histogram.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/histogram.cc b/histogram.cc index fab6b82..2e68c20 100644 --- a/histogram.cc +++ b/histogram.cc @@ -70,8 +70,8 @@ void cb_histogramda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da int histogram_width = histogram_zoom_stop - histogram_zoom_start; for (int i = 0; i < histogram_width; i++) { - px = HISTOGRAM_MARGIN + ((clientw-HISTOGRAM_MARGIN*2) * i) / histogram_width; - py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * histogram[chan][histogram_zoom_start+i]) / histogram_max; + px = HISTOGRAM_MARGIN + ((clientw-HISTOGRAM_MARGIN*2) * i) / histogram_width; + py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * log10(histogram[chan][histogram_zoom_start+i]+1) / log10(histogram_max)); if (i == 0) cairo_move_to(cr, px, py2); else cairo_line_to(cr, px, py2); @@ -202,13 +202,13 @@ void cb_histogramda_btnrelease (GtkWidget *widget, gpointer data) { // translate first coordinate histogram_zoom_start = (histogram_pressed_x - HISTOGRAM_MARGIN) * HISTOGRAM_WIDTH / (clientw - HISTOGRAM_MARGIN*2); if (histogram_zoom_start < 0) histogram_zoom_start = 0; - if (histogram_zoom_start > 256) histogram_zoom_start = 256; + if (histogram_zoom_start > HISTOGRAM_WIDTH) histogram_zoom_start = HISTOGRAM_WIDTH; // translate second coordinate histogram_zoom_stop = (histogram_released_x - HISTOGRAM_MARGIN) * HISTOGRAM_WIDTH / (clientw - HISTOGRAM_MARGIN*2) + 1; // limit the values if (histogram_zoom_stop < 0) histogram_zoom_stop = 0; - if (histogram_zoom_stop > 256) histogram_zoom_stop = 256; + if (histogram_zoom_stop > HISTOGRAM_WIDTH) histogram_zoom_stop = HISTOGRAM_WIDTH; // exchange the values if necessary if (histogram_zoom_start > histogram_zoom_stop) {