Author: Carlos Lopez <genet...@gmail.com> Date: Thu Dec 6 13:42:30 2012 +0100
CairoImporter: set the default gamma to 2.2 to match the current status. It has of be fixed some day. :-/ Add code to modify the gamma of the imported image to match the gamma of the application. --- synfig-core/src/modules/mod_png/mptr_cairo_png.cpp | 20 +++++++++++++++++++- synfig-core/src/synfig/cairoimporter.cpp | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/synfig-core/src/modules/mod_png/mptr_cairo_png.cpp b/synfig-core/src/modules/mod_png/mptr_cairo_png.cpp index 6acad1a..2aa5c36 100644 --- a/synfig-core/src/modules/mod_png/mptr_cairo_png.cpp +++ b/synfig-core/src/modules/mod_png/mptr_cairo_png.cpp @@ -66,7 +66,25 @@ cairo_png_mptr::cairo_png_mptr(const char *file_name) if(csurface_ && !cairo_surface_status(csurface_)) cairo_surface_destroy(csurface_); csurface_=cairo_image_surface_create_from_png(file_name); - + CairoSurface cairo_s; + cairo_s.set_cairo_surface(csurface_); + cairo_s.map_cairo_image(); + int w=cairo_s.get_w(); + int h=cairo_s.get_h(); + for(int y=0; y<h; y++) + for(int x=0; x<w; x++) + { + CairoColor c=cairo_s[y][x]; + float a=c.get_alpha(); + unsigned char r=(unsigned char)(a*gamma().r_F32_to_F32(c.get_r()/a)); + unsigned char g=(unsigned char)(a*gamma().g_F32_to_F32(c.get_g()/a)); + unsigned char b=(unsigned char)(a*gamma().b_F32_to_F32(c.get_b()/a)); + c.set_r(r); + c.set_g(g); + c.set_b(b); + cairo_s[y][x]=c; + } + cairo_s.unmap_cairo_image(); } cairo_png_mptr::~cairo_png_mptr() diff --git a/synfig-core/src/synfig/cairoimporter.cpp b/synfig-core/src/synfig/cairoimporter.cpp index 6d0ee4e..95f24af 100644 --- a/synfig-core/src/synfig/cairoimporter.cpp +++ b/synfig-core/src/synfig/cairoimporter.cpp @@ -126,8 +126,8 @@ CairoImporter::open(const String &filename) return 0; } -CairoImporter::CairoImporter()//: - //gamma_(2.2) +CairoImporter::CairoImporter(): + gamma_(2.2) { } ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Synfig-devl mailing list Synfig-devl@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synfig-devl