Module: synfig Branch: nikitakit_svg Commit: 16ad7837f0dd6c39091dbaa8f399b6f0b97e5f4f URL: http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig;a=commit;h=16ad7837f0dd6c39091dbaa8f399b6f0b97e5f4f
Author: Nikita Kitaev <nikita...@gmail.com> Date: Thu Apr 1 19:29:16 2010 -0700 Make SVG import parse 3-digit hex color values --- synfig-core/src/modules/mod_svg/svg_parser.cpp | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/synfig-core/src/modules/mod_svg/svg_parser.cpp b/synfig-core/src/modules/mod_svg/svg_parser.cpp index f7b6350..1a35849 100644 --- a/synfig-core/src/modules/mod_svg/svg_parser.cpp +++ b/synfig-core/src/modules/mod_svg/svg_parser.cpp @@ -1853,6 +1853,8 @@ Svg_parser::randomLetter(){ int Svg_parser::getRed(String hex){ if(hex.at(0)=='#'){ + //allow for 3-digit hex codes (#rgb = #rrggbb) + if (hex.length()<7) return (16+1) * hextodec(hex.substr(1,1)); return hextodec(hex.substr(1,2)); }else if(hex.compare(0,3,"rgb")==0 || hex.compare(0,3,"RGB")==0){ int start=hex.find_first_of("(")+1; @@ -1865,6 +1867,7 @@ Svg_parser::getRed(String hex){ int Svg_parser::getGreen(String hex){ if(hex.at(0)=='#'){ + if (hex.length()<7) return (16+1) * hextodec(hex.substr(2,1)); return hextodec(hex.substr(3,2)); }else if(hex.compare(0,3,"rgb")==0 || hex.compare(0,3,"RGB")==0){ int start=hex.find_first_of("(")+1; @@ -1877,6 +1880,7 @@ Svg_parser::getGreen(String hex){ int Svg_parser::getBlue(String hex){ if(hex.at(0)=='#'){ + if (hex.length()<7) return (16+1) * hextodec(hex.substr(3,1)); return hextodec(hex.substr(5,2)); }else if(hex.compare(0,3,"rgb")==0 || hex.compare(0,3,"RGB")==0){ int start=hex.find_first_of("(")+1; ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Synfig-devl mailing list Synfig-devl@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synfig-devl