[giv] Fixed png error. Work in progress on text in measurement tool.
- From: Dov Grobgeld <dov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [giv] Fixed png error. Work in progress on text in measurement tool.
- Date: Fri, 8 Apr 2011 08:13:54 +0000 (UTC)
commit 8b50cdd963180c649772fe2b31d07bf3e50002eb
Author: Dov Grobgeld <dov grobgeld gmail com>
Date: Fri Apr 8 11:13:27 2011 +0300
Fixed png error. Work in progress on text in measurement tool.
ChangeLog | 7 +++++++
configure.in | 2 +-
src/giv-win.gob | 47 ++++++++++++++++++++++++++++++++---------------
src/givimage.c | 2 +-
src/givplugin.c | 4 ++--
src/plugins/SConscript | 2 +-
src/plugins/png.c | 10 ++++++++--
7 files changed, 52 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 94a20e2..f202b0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-04-08 Dov Grobgeld <dov grobgeld gmail com>
+
+ * png.c : Fixed error when reading 8-bit png images.
+
+ * giv-win.gob : Made info label update when changing pixel size
+ info.
+
2011-04-06 Dov Grobgeld <dov grobgeld gmail com>
* plugins/png.c : png plugin with support for 16-bit png files.
diff --git a/configure.in b/configure.in
index 6dfebf3..4e8db08 100644
--- a/configure.in
+++ b/configure.in
@@ -5,7 +5,7 @@ AM_CONFIG_HEADER(config.h)
PACKAGE=givwidget
GIVWIDGET_API_VERSION=2.0
-AM_INIT_AUTOMAKE(giv, 0.9.18)
+AM_INIT_AUTOMAKE(giv, 0.9.19)
dnl Use libtool to get shared libraries
LT_PREREQ
diff --git a/src/giv-win.gob b/src/giv-win.gob
index 431dd2d..f57a3af 100644
--- a/src/giv-win.gob
+++ b/src/giv-win.gob
@@ -1376,6 +1376,29 @@ class Giv:Win from Gtk:Window
{
return selfp->img_org;
}
+
+ public void
+ update_pixelsize_info(self,
+ GString *info_label)
+ {
+ char format[128];
+ int precision = 0;
+ if (selfp->do_show_sub_pixel)
+ precision = 3;
+ sprintf(format, " (%%.%df,%%.%df) dist=%%.3f%%s (%%.2f%%s,%%.2f%%s)",
+ precision,precision);
+
+ g_string_sprintf(info_label, format,
+ selfp->measure_x2,
+ selfp->measure_y2,
+ selfp->last_measure_distance_in_pixels*selfp->pixelsize,
+ selfp->pixelsize_unit,
+ (selfp->measure_x2 - selfp->measure_x1)*selfp->pixelsize,
+ selfp->pixelsize_unit,
+ (selfp->measure_y2 - selfp->measure_y1)*selfp->pixelsize,
+ selfp->pixelsize_unit
+ );
+ }
}
%{
@@ -1666,20 +1689,7 @@ cb_motion_event(GtkWidget *widget,
x,y);
#endif
dovtk_lasso_update(selfp->lasso);
- if (!selfp->do_show_sub_pixel)
- g_string_sprintf(info_label, " (%.0f,%.0f) dist=%.3f (%.2f,%.2f)",
- x,y,
- m_dist,
- x - selfp->measure_x1,
- y - selfp->measure_y1
- );
- else
- g_string_sprintf(info_label, " (%.3f,%.3f) dist=%.3f (%.3f,%.3f)",
- x,y,
- m_dist,
- x - selfp->measure_x1,
- y - selfp->measure_y1
- );
+ giv_win_update_pixelsize_info(self, info_label);
}
else
do_update_label = false;
@@ -2085,6 +2095,11 @@ cb_calib_changed(GtkWidget *calib_dialog,
selfp->pixelsize_unit = g_strdup(unit);
if (selfp->lasso)
dovtk_lasso_update(selfp->lasso);
+
+ GString *info_label = g_string_new("");
+ giv_win_update_pixelsize_info(self, info_label);
+ gtk_label_set(GTK_LABEL(selfp->w_info_label), info_label->str);
+ g_string_free(info_label, TRUE);
}
static void
@@ -3540,6 +3555,8 @@ draw_caliper(cairo_t *cr,
cairo_fill(cr);
#ifdef CAIRO_HAS_WIN32_FONT
+ // This is stil broken!
+
// As I can't get pango cairo to work under Windows, I use the specific windows
// backend which fortunately works.
LOGFONTW lf;
@@ -3588,7 +3605,7 @@ draw_caliper(cairo_t *cr,
int layout_width, layout_height;
pango_layout_get_size(pango_layout, &layout_width, &layout_height);
- cairo_move_to(cr, -0.5*layout_width/PANGO_SCALE,-20);
+ cairo_move_to(cr, -0.5*layout_width/PANGO_SCALE,-0.2*layout_height);
if (!do_mask)
cairo_set_source_rgba(cr, 0,0,0,1); // 0x50/255.0,0x2d/255.0,0x16/255.0,1);
diff --git a/src/givimage.c b/src/givimage.c
index 98f185c..59d70dd 100644
--- a/src/givimage.c
+++ b/src/givimage.c
@@ -618,7 +618,7 @@ GdkPixbuf *giv_image_get_pixbuf(GivImage *img,
// Silently ignore 16 bit images at the moment
if (img->img_type == GIVIMAGE_RGB_U16) {
for (row_idx=0; row_idx<height; row_idx++) {
- gchar *row = pbuf + row_idx * pb_rowstride;
+ guchar *row = pbuf + row_idx * pb_rowstride;
for (col_idx=0; col_idx<width; col_idx++) {
GivImageRgb16 rgb16
= giv_image_get_rgb_value(img,
diff --git a/src/givplugin.c b/src/givplugin.c
index 724ede5..eafd643 100644
--- a/src/givplugin.c
+++ b/src/givplugin.c
@@ -18,7 +18,7 @@ typedef gboolean (* SupportsFile) (const char *filename,
guchar *start_chunk,
gint start_chunk_len);
typedef GivImage* (* LoadFile)(const char *filename,
- GError *error);
+ GError **error);
// TBD: Support a comma separated list of plugin directories.
static void rehash_loaders()
@@ -52,7 +52,7 @@ static void rehash_loaders()
const gchar *name;
while( (name=g_dir_read_name(plugin_dir)) ) {
- printf("name = %s\n", name);
+ // printf("name = %s\n", name);
// Try to load it as a module if it ends with ".dll"
// or ".so".
gchar *extension = g_strrstr(name, ".");
diff --git a/src/plugins/SConscript b/src/plugins/SConscript
index 3a08ae3..bb15c03 100644
--- a/src/plugins/SConscript
+++ b/src/plugins/SConscript
@@ -36,7 +36,7 @@ if not env['SBOX']:
env.SharedLibrary('png',
['png.c'],
LIBPATH=['..','../gtkimageviewer','../agg','../pcre','../plis'] + env['LIBPATH'],
- LIBS=['png','z','giv-image']+env['LIBS'],
+ LIBS=['giv-image']+env['LIBS'],
)
SConscript('dcmtk/SConscript',
diff --git a/src/plugins/png.c b/src/plugins/png.c
index 8235679..a639361 100644
--- a/src/plugins/png.c
+++ b/src/plugins/png.c
@@ -78,16 +78,22 @@ GivImage *giv_plugin_load_file(const char *filename,
&bit_depth, &color_type, &interlace_type,
&compression_type, &filter_method);
+#if 0
printf("width height bit_depth color_type = %d %d %d %d\n",
(int)width, (int)height,
bit_depth, color_type);
-
+#endif
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png_ptr);
+ // Since giv doesn't support gray alpha, we upgrade to rgb
+ if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ png_set_gray_to_rgb(png_ptr);
+
if (color_type == PNG_COLOR_TYPE_GRAY &&
- bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
+ bit_depth < 8)
+ png_set_expand_gray_1_2_4_to_8(png_ptr);
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(png_ptr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]