From f47d3775340223cb12b03e16cf3c0a56d45f4dee Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 4 Apr 2010 11:35:55 +0000 Subject: [PATCH] fix stupid bug in histogram window. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1438 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/palette.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/palette.c b/src/palette.c index b366f6e7..72c0d185 100644 --- a/src/palette.c +++ b/src/palette.c @@ -762,7 +762,7 @@ void Draw_all_palette_sliders(T_Scroller_button * red_slider, void Window_Histogram(unsigned char block_start, unsigned char block_end, dword* color_usage) { - int i; + int i, j; unsigned int max_count = 0; /* Draws an histogram of the selected range in a separate window */ @@ -787,20 +787,25 @@ void Window_Histogram(unsigned char block_start, unsigned char block_end, dword* Window_set_normal_button(120, 120, 42, 14, "Close",-1,1,SDLK_RETURN); // Step 2 : draw bars + j = 0; for(i=block_start; i<= block_end; i++) { - Block( - ToWinX(3+i*256/(block_end-block_start+1)), - ToWinY(117-100*color_usage[i]/max_count), - ToWinL(256/(block_end-block_start+1)), - ToWinH(100*color_usage[i]/max_count), i); + Block( + ToWinX(3+j*(256/(block_end-block_start+1))), + ToWinY(117-100*color_usage[i]/max_count), + ToWinL(256/(block_end-block_start+1)), + ToWinH(100*color_usage[i]/max_count), i); - if (i == MC_Light) - Block( - ToWinX(3+i*256/(block_end-block_start+1)), - ToWinY(117-100*color_usage[i]/max_count), - ToWinL(256/(block_end-block_start+1)), - ToWinH(1),MC_Black); + if (i == MC_Light) { + Block( + ToWinX(3+j*256/(block_end-block_start+1)), + ToWinY(117-100*color_usage[i]/max_count), + ToWinL(256/(block_end-block_start+1)), + ToWinH(1),MC_Black); + } + + j++; } + Update_window_area(0,0,263,140); Display_cursor(); @@ -940,7 +945,7 @@ void Button_Palette(void) // histogram button button_used = Window_set_normal_button(228,47,64,14,"000000",0,1,SDLK_d);// 15 - Window_set_normal_button(210,17,83,14,"Zap unused",0,1,SDLK_DELETE);//16 + Window_set_normal_button(209,17,83,14,"Zap unused",0,1,SDLK_DELETE);//16 Window_set_repeatable_button(266, 74,12,11,"+",0,1,SDLK_KP_PLUS); // 17 Window_set_repeatable_button(266,165,12,11,"-",0,1,SDLK_KP_MINUS); // 18