comparison src/image-overlay.c @ 290:4bbde8a38ad4

improved histogram drawing
author nadvornik
date Wed, 09 Apr 2008 20:49:32 +0000
parents 9995c5fb202a
children cb93a982fcdd
comparison
equal deleted inserted replaced
289:6a7298988a7a 290:4bbde8a38ad4
72 #define OSD_INFO_X 10 72 #define OSD_INFO_X 10
73 #define OSD_INFO_Y -10 73 #define OSD_INFO_Y -10
74 74
75 #define IMAGE_OSD_DEFAULT_DURATION 30 75 #define IMAGE_OSD_DEFAULT_DURATION 30
76 76
77 #define HISTOGRAM_HEIGHT 140
77 /* 78 /*
78 *---------------------------------------------------------------------------- 79 *----------------------------------------------------------------------------
79 * image histogram 80 * image histogram
80 *---------------------------------------------------------------------------- 81 *----------------------------------------------------------------------------
81 */ 82 */
324 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++) 325 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
325 { 326 {
326 active_marks += fd->marks[mark]; 327 active_marks += fd->marks[mark];
327 } 328 }
328 329
329 if (with_hist)
330 {
331 text2 = g_strdup_printf("%s\n%s", text, histogram_label(lw->histogram));
332 g_free(text);
333 text = text2;
334 }
335 330
336 if (active_marks > 0) 331 if (active_marks > 0)
337 { 332 {
338 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2); 333 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
339 334
346 g_string_free(buf, TRUE); 341 g_string_free(buf, TRUE);
347 g_free(text); 342 g_free(text);
348 text = text2; 343 text = text2;
349 } 344 }
350 345
346 if (with_hist)
347 {
348 text2 = g_strdup_printf("%s\n%s", text, histogram_label(lw->histogram));
349 g_free(text);
350 text = text2;
351 }
351 } 352 }
352 } 353 }
353 354
354 layout = gtk_widget_create_pango_layout(imd->pr, NULL); 355 layout = gtk_widget_create_pango_layout(imd->pr, NULL);
355 pango_layout_set_markup(layout, text, -1); 356 pango_layout_set_markup(layout, text, -1);
362 363
363 if (with_hist) 364 if (with_hist)
364 { 365 {
365 histogram_read(lw->histogram, imgpixbuf); 366 histogram_read(lw->histogram, imgpixbuf);
366 if (width < 266) width = 266; 367 if (width < 266) width = 266;
367 height += 256; 368 height += HISTOGRAM_HEIGHT + 5;
368 } 369 }
369 370
370 371
371 /* TODO: make osd color configurable --Zas */ 372 /* TODO: make osd color configurable --Zas */
372 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); 373 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
378 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0); 379 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
379 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0); 380 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
380 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0); 381 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
381 382
382 if (with_hist) 383 if (with_hist)
383 histogram_draw(lw->histogram, pixbuf, 0, 0, width, height); 384 histogram_draw(lw->histogram, pixbuf, 5, height - HISTOGRAM_HEIGHT - 5 , width - 10, HISTOGRAM_HEIGHT);
384 385
385 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255); 386 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
386 387
387 g_object_unref(G_OBJECT(layout)); 388 g_object_unref(G_OBJECT(layout));
388 389