Added copyright lines for files I've edited this year.
[synfig.git] / synfig-core / trunk / src / synfig / layer_composite.cpp
index 7381017..6a25efc 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -155,16 +156,41 @@ Layer_Composite::set_param(const String & param, const ValueBase &value)
        else
        if(param=="blend_method" && value.same_type_as(int()))
        {
-               Color::BlendMethod blend_method = static_cast<Color::BlendMethod>(value.get(int()));
+               blend_method_ = static_cast<Color::BlendMethod>(value.get(int()));
 
-               if (blend_method < 0 || blend_method >= Color::BLEND_END)
+               if (blend_method_ < 0 || blend_method_ >= Color::BLEND_END)
                {
-                       warning("illegal value (%d) for blend_method - using Composite instead", blend_method);
+                       warning("illegal value (%d) for blend_method - using Composite instead", blend_method_);
                        blend_method_ = Color::BLEND_COMPOSITE;
                        return false;
                }
 
-               blend_method_ = blend_method;
+               if (blend_method_ == Color::BLEND_STRAIGHT && !reads_context())
+               {
+                       Canvas::Handle canvas(get_canvas());
+                       if (canvas)
+                       {
+                               String version(canvas->get_version());
+
+                               if (version == "0.1" || version == "0.2")
+                               {
+                                       if (get_name() == "PasteCanvas")
+                                               warning("loaded a version %s canvas with a 'Straight' blended PasteCanvas (%s) - check it renders OK",
+                                                               version.c_str(), get_non_empty_description().c_str());
+                                       else
+                                       {
+                                               blend_method_ = Color::BLEND_COMPOSITE;
+                                               converted_blend_ = true;
+
+                                               // if this layer has a transparent color, go back and set the color again
+                                               // now that we know we are converting the blend method as well.  that will
+                                               // make the color non-transparent, and change the blend method to alpha over
+                                               if (transparent_color_)
+                                                       set_param("color", get_param("color"));
+                                       }
+                               }
+                       }
+               }
        }
        else
                return Layer::set_param(param,value);