diff --git a/xtt/lib/glow/gtk/glow_draw_gtk.cpp b/xtt/lib/glow/gtk/glow_draw_gtk.cpp index 3e52a92891cd70104e3e888275912d39fc9e60f1..6c5f1a6eb9556d88225f4c1b037a400f7542ab58 100644 --- a/xtt/lib/glow/gtk/glow_draw_gtk.cpp +++ b/xtt/lib/glow/gtk/glow_draw_gtk.cpp @@ -2812,6 +2812,14 @@ unsigned char *GlowDrawGtk::image_get_data( glow_tImImage image) return (unsigned char *) gdk_pixbuf_get_pixels( (GdkPixbuf *)image); } +void GlowDrawGtk::image_copy( glow_tImImage orig_image, glow_tImImage *image) +{ + if ( *image) + gdk_pixbuf_unref( (GdkPixbuf *)*image); + + *(GdkPixbuf **)image = gdk_pixbuf_copy( (GdkPixbuf *)orig_image); +} + void GlowDrawGtk::image_rotate( glow_tImImage *image, int to_rotation, int from_rotation) { #if GDK_PIXBUF_MAJOR == 2 && GDK_PIXBUF_MINOR < 8 @@ -2899,8 +2907,9 @@ int GlowDrawGtk::image_load( char *imagefile, return 0; } - if ( im) + if ( im) { *im = (glow_tImImage *) gdk_pixbuf_copy( (GdkPixbuf *)*orig_im); + } return 1; } diff --git a/xtt/lib/glow/gtk/glow_draw_gtk.h b/xtt/lib/glow/gtk/glow_draw_gtk.h index a347d52994091f44d63af0707feb3f2e3970bccd..bd76d187e67c1cc675c3cc15deba4779b8faea36 100644 --- a/xtt/lib/glow/gtk/glow_draw_gtk.h +++ b/xtt/lib/glow/gtk/glow_draw_gtk.h @@ -201,6 +201,7 @@ class GlowDrawGtk : public GlowDraw { int image_get_height( glow_tImImage image); int image_get_rowstride( glow_tImImage image); unsigned char *image_get_data( glow_tImImage image); + void image_copy( glow_tImImage orig_image, glow_tImImage *image); void image_rotate( glow_tImImage *image, int to_rotation, int from_rotation); void image_flip_vertical( glow_tImImage *image); void image_flip_horizontal( glow_tImImage *image); diff --git a/xtt/lib/glow/src/glow_draw.h b/xtt/lib/glow/src/glow_draw.h index 271a64d1cf40c624c88a0e20a3bc9a7a28dcbb9c..19799d011e5d04ba27764fc389089d76a43f6b8c 100644 --- a/xtt/lib/glow/src/glow_draw.h +++ b/xtt/lib/glow/src/glow_draw.h @@ -151,6 +151,7 @@ class GlowDraw { virtual int image_get_height( glow_tImImage image) {return 0;} virtual int image_get_rowstride( glow_tImImage image) {return 0;} virtual unsigned char *image_get_data( glow_tImImage image) {return 0;} + virtual void image_copy( glow_tImImage orig_image, glow_tImImage *image) {} virtual void image_rotate( glow_tImImage *image, int to_rotation, int from_rotation) {} virtual void image_flip_vertical( glow_tImImage *image) {} virtual void image_flip_horizontal( glow_tImImage *image) {} diff --git a/xtt/lib/glow/src/glow_growimage.cpp b/xtt/lib/glow/src/glow_growimage.cpp index 19a9454c7469e6e4ad1fa8d08d0e134f30daa75b..1fd937da0e49648c0c20b419be35e5f8c4c4d317 100644 --- a/xtt/lib/glow/src/glow_growimage.cpp +++ b/xtt/lib/glow/src/glow_growimage.cpp @@ -198,6 +198,7 @@ int GrowImage::insert_image( const char *imagefile) ctx->gdraw->image_load( filename, &original_image, &image); if ( !original_image) return 0; + current_width = int( ctx->mw.zoom_factor_x / ctx->mw.base_zoom_factor * ctx->gdraw->image_get_width( image)); current_height = int( ctx->mw.zoom_factor_y / ctx->mw.base_zoom_factor * @@ -1219,6 +1220,9 @@ int GrowImage::set_image_color( glow_tImImage om, void *n) c_color_shift || c_color_intensity || c_color_lightness || inverse) { ctx->gdraw->image_pixel_iter( om, &image, pixel_cb, this); } + else if ( image != om) + ctx->gdraw->image_copy( om, &image); + return 1; }