C++ SVG library

Overview

SVG++ library 1.3.0

Please visit http://svgpp.org/ for description, tutorial and reference.

About

SVG++ library can be thought of as a framework, containing parsers for various SVG syntaxes, adapters that simplify handling of parsed data and a lot of other utilities and helpers for the most common tasks. Take a look at Tutorial to get the idea about what it is.

SVG++ features

  • Is a header-only library

  • Can be used with any XML parser

  • Compile time configured - no virtual functions

  • Minimal runtime overhead - you pay only for what you get

  • Has wide range of possible uses:

    • Fully functional, conforming SVG viewers
    • Simple in-app SVG rasterizers
    • Import modules of vector editing software
    • Implementing path-only input of SVG format with minimal efforts in any graphics or math software
  • Requires only Boost library itself (demo, tests and sample have their own requirements)

  • Compatible with C++11, but requires conforming implementation, due to heavy usage of templates

  • Supports any character type (char and wchar_t). Other (Unicode from C++11) were not tested, but should be ok.

SVG 1.1 features covered by SVG++

  • Path data - parsing, simplification
  • Transform list - parsing, simplification
  • Color, including ICC color - parsing
  • Lengths - highly configurable handling of SVG lengths, full support of all SVG length units
  • Basic shapes - optional conversion to path
  • Style attribute - parsing, taking in account differences in parsing presentation attributes and style properties
  • Automatic marker positions calculation
  • Viewport and viewbox handling

SVG++ is NOT

  • An SVG viewer or library that produces raster image from SVG (though C++ demo app included, which renders SVG with AGG, GDI+ or Skia graphics library)
  • Renders anything itself

What's new

How to Help

  • CSS Processor. Processing CSS is outside of SVG++ scope, but it'll be nice to have some generic implementation of CSS selectors to use at preprocessing stage.
  • SVG Filter Effects. Some filters are already implemented in demo application but the complete solution requires more efforts. Generic enough parts may fit in SVG++ source base. Usage of Boost.GIL may make the code more reusable.
  • Animation. Implementation of animation in the demo application. Probably some utilities may get to SVG++.
  • Try to reduce compiler memory usage by switching to some C++11 metaprogramming library (brigand?). Evaluate upgrade to Boost.Spirit 3.0.
  • Extend demo with Cairo support?
  • More wrappers for XML parsers?
  • Evolve demo to fully functional SVG rendering component for one of the graphic engines. A major gap in demo's SVG implementation is text and font support. It'll be too complex to make it cross-engine, but for the single engine chosen and probably with third-party libraries like FreeType it's pretty feasible.
Comments
  • tspan attributes

    tspan attributes

    I am not notified of attributes on elements in the following simplified SVG

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <svg>
       <text xml:id="test_svgpp_sample.test_sample">
         <tspan justification="center">
           <tspan x="2.00" y="72.00" textLength="304.00" font-family="Century Gothic" font-size="72.00" fill="#ff0000">Hello</tspan>
           <tspan x="61.00" y="159.00" textLength="184.00" font-family="Century Gothic" font-size="72.00" fill="#ff0000">World</tspan>
         </tspan>
      </text>
    </svg>
    

    When I run the unit test that parses this SVG I get:

    QDEBUG : test_svgpp_sample::test_sample() onPushElement() Text
    QDEBUG : test_svgpp_sample::test_sample() onAttribute() id test_svgpp_sample.test_sample
    QDEBUG : test_svgpp_sample::test_sample() onPushElement() TSpan
    QDEBUG : test_svgpp_sample::test_sample() onAttribute() justification center
    QDEBUG : test_svgpp_sample::test_sample() onPushElement() TSpan
    QDEBUG : test_svgpp_sample::test_sample() onText() Hello
    QDEBUG : test_svgpp_sample::test_sample() onPopElement()
    QDEBUG : test_svgpp_sample::test_sample() onPushElement() TSpan
    QDEBUG : test_svgpp_sample::test_sample() onText() World
    QDEBUG : test_svgpp_sample::test_sample() onPopElement()
    QDEBUG : test_svgpp_sample::test_sample() onPopElement()
    QDEBUG : test_svgpp_sample::test_sample() onPopElement()
    

    Where are my callbacks for attributes x, y, textLength, font-family, font-size and fill?


    These are my processed elements

    using processed_elements_t = boost::mpl::set <
                                     // SVG Structural Elements
                                     svgpp::tag::element::svg,
                                     svgpp::tag::element::g,
                                     // SVG Shape Elements
                                     svgpp::tag::element::circle,
                                     svgpp::tag::element::ellipse,
                                     svgpp::tag::element::line,
                                     svgpp::tag::element::path,
                                     svgpp::tag::element::polygon,
                                     svgpp::tag::element::polyline,
                                     svgpp::tag::element::rect,
                                     svgpp::tag::element::style,
                                     svgpp::tag::element::text,
                                     svgpp::tag::element::title,
                                     svgpp::tag::element::tspan
                                     >::type;
    

    And these are my processed attributes

    using processed_attributes_t = boost::mpl::insert<
                                     svgpp::traits::shapes_attributes_by_element,
                                     svgpp::tag::attribute::transform
                                     >::type;
    
    opened by mawnlower 12
  • New vulnerability

    New vulnerability

    id_000015,sig_11,src_001176,time_147681735,op_arith8,pos_10,val_+3.zip 在renderDocument函数中的XMLDocument::getRoot函数对XMLDocument对象处理不当,在第二个if处提前返回一个空指针,造成renderDocument函数后面有空指针引用。 The XMLDocument::getRoot function in the renderDocument function handled the XMLDocument object improperly, returning a null pointer in advance at the second if, resulting in a null pointer reference behind the renderDocument function.

    AddressSanitizer:DEADLYSIGNAL

    ==1486083==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000006d742e bp 0x7fffc6d83dd0 sp 0x7fffc6d83880 T0) ==1486083==The signal is caused by a READ memory access. ==1486083==Hint: address points to the zero page. #0 0x6d742e in rapidxml_ns::xml_base::local_name() const /home/zero/Desktop/svgpp-master/src/demo/render/../../../third_party/rapidxml_ns/rapidxml_ns.hpp:882:20 #1 0x6d742e in svgpp::policy::xml::element_iterator<rapidxml_ns::xml_node const*>::get_local_name(rapidxml_ns::xml_node const*) /home/zero/Desktop/svgpp-master/src/demo/render/../../../include/svgpp/policy/xml/rapidxml_ns.hpp:127:43 #2 0x6d742e in bool svgpp::document_traversal<svgpp::context_factories<child_context_factories>, svgpp::length_policy<svgpp::policy::length::forward_to_method<Canvas, svgpp::factory::length::unitless<double, double, svgpp::tag::length_units::mm> const> >, svgpp::color_factory<svgpp::factory::color::percentage_adapter<color_factory_base_t> >, svgpp::processed_elements<processed_elements>, svgpp::processed_attributes<processed_attributes>, svgpp::path_policy<path_policy>, svgpp::document_traversal_control_policy, svgpp::transform_events_policy<svgpp::policy::transform_events::forward_to_method >, svgpp::path_events_policy<svgpp::policy::path_events::forward_to_method >, svgpp::error_policy<svgpp::policy::error::default_policy >, svgpp::markers_policysvgpp::policy::markers::calculate_always, svgpp::attribute_traversal_policy<attribute_traversal>, svgpp::viewport_policysvgpp::policy::viewport::as_transform >::load_expected_element<rapidxml_ns::xml_node const*, Canvas, svgpp::tag::element::svg>(rapidxml_ns::xml_node const* const&, Canvas&, svgpp::tag::element::svg) /home/zero/Desktop/svgpp-master/src/demo/render/../../../include/svgpp/document_traversal.hpp:108:61 #3 0x6d742e in bool svgpp::document_traversal<svgpp::context_factories<child_context_factories>, svgpp::length_policy<svgpp::policy::length::forward_to_method<Canvas, svgpp::factory::length::unitless<double, double, svgpp::tag::length_units::mm> const> >, svgpp::color_factory<svgpp::factory::color::percentage_adapter<color_factory_base_t> >, svgpp::processed_elements<processed_elements>, svgpp::processed_attributes<processed_attributes>, svgpp::path_policy<path_policy>, svgpp::document_traversal_control_policy, svgpp::transform_events_policy<svgpp::policy::transform_events::forward_to_method >, svgpp::path_events_policy<svgpp::policy::path_events::forward_to_method >, svgpp::error_policy<svgpp::policy::error::default_policy >, svgpp::markers_policysvgpp::policy::markers::calculate_always, svgpp::attribute_traversal_policy<attribute_traversal>, svgpp::viewport_policysvgpp::policy::viewport::as_transform >::load_document<rapidxml_ns::xml_node const*, Canvas>(rapidxml_ns::xml_node const* const&, Canvas&) /home/zero/Desktop/svgpp-master/src/demo/render/../../../include/svgpp/document_traversal.hpp:97:12 #4 0x6d742e in renderDocument(XMLDocument&, ImageBuffer&) /home/zero/Desktop/svgpp-master/src/demo/render/svgpp_render.cpp:1659:3 #5 0x6d8b32 in main /home/zero/Desktop/svgpp-master/src/demo/render/svgpp_render.cpp:1683:7 #6 0x7fb2c6bd3d09 in __libc_start_main csu/../csu/libc-start.c:308:16 #7 0x606bc9 in _start (/home/zero/Desktop/svgpp-master/src/source/bin/svgpp_agg_render+0x606bc9)

    AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /home/zero/Desktop/svgpp-master/src/demo/render/../../../third_party/rapidxml_ns/rapidxml_ns.hpp:882:20 in rapidxml_ns::xml_base::local_name() const ==1486083==ABORTING

    credit:Cvjark,上帝的玩具

    opened by 001SM 6
  • Error reading file Reinel_compass_rose.svg in element path

    Error reading file Reinel_compass_rose.svg in element path

    Tried render Reinel_compass_rose.svg with svgpp_agg_render example.

    Error reading file Reinel_compass_rose.svg in element "path": Invalid value of SVG attribute (or property) "d": "M0 h94 m9 h49 m12 h51"

    http://upload.wikimedia.org/wikipedia/commons/e/eb/Reinel_compass_rose.svg

    opened by sakrist 6
  • Compiling error

    Compiling error

    I am receiving some errors compiling svgpp (when building another library that uses svgpp).

    First it was giving me some error about implicitly deleting boost::noncopyable because it would form an invalid constructor/function. Sorry I don't remember exactly and I didn't write down that error.

    So I pulled the last version of svgpp from the repository. And it now gives this error.

    Maybe someone can shed some light. Thanks in advance.

    /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/external/svgpp/include/svgpp/policy/value_events.hpp:23:5: error: no matching function for call to ‘Canvas::set(svgpp::tag::attribute::fill&, const int&, const svgpp::tag::skip_icc_color&)’ 23 | context.set(tag, args...); | ^~~~~~~ /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:36:10: note: candidate: ‘void Stylable::set(svgpp::tag::attribute::stroke_width, float)’ 36 | void set(tag::attribute::stroke_width, float val) { stroke_width = val; } | ^~~ /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:36:10: note: candidate expects 2 arguments, 3 provided /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:37:10: note: candidate: ‘void Stylable::set(svgpp::tag::attribute::stroke, svgpp::tag::value::none)’ 37 | void set(tag::attribute::stroke, tag::value::none) { stroke_paint = tag::value::none(); } | ^~~ /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:37:10: note: candidate expects 2 arguments, 3 provided /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:38:10: note: candidate: ‘void Stylable::set(svgpp::tag::attribute::stroke, svgpp::tag::value::currentColor)’ 38 | void set(tag::attribute::stroke, tag::value::currentColor) { stroke_paint = tag::value::currentColor(); } | ^~~ /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:38:10: note: candidate expects 2 arguments, 3 provided /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:39:10: note: candidate: ‘void Stylable::set(svgpp::tag::attribute::stroke, std::experimental::io2d::v1::rgba_color, svgpp::tag::skip_icc_color)’ 39 | void set(tag::attribute::stroke, rgba_color color, tag::skip_icc_color = tag::skip_icc_color()) { stroke_paint = color; } | ^~~ /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:39:14: note: no known conversion for argument 1 from ‘svgpp::tag::attribute::fill’ to ‘svgpp::tag::attribute::stroke’ 39 | void set(tag::attribute::stroke, rgba_color color, tag::skip_icc_color = tag::skip_icc_color()) { stroke_paint = color; } | ^~~~~~~~~~~~~~~~~~~~~~ /home/jm/projects/P0267_RefImpl/P0267_RefImpl/Samples/svg/svg.cpp:41:10: note: candidate: ‘template void Stylable::set(svgpp::tag::attribute::stroke, const IRI&)’ 41 | void set(tag::attribute::stroke /tag/, IRI const & /iri/) { throw std::runtime_error("Non-local references aren't supported"); } | ^~~

    opened by J-M-O-R 4
  • Empty SVGs in samples

    Empty SVGs in samples

    I've question regarding samples, actually it's not only about Sample01a but other samples too. So in main function we have: char text[] = "< svg / >"; and this text is being used by xml parser which means this is our svg sample, right? If yes then our hooks methods declared in Context class should be called appropriately, so if I'll add some logging inside them I should observe some actions, but question is if this code "< svg / >" is enough? It might be obvious but it's not. I'm not seeing any logging even for quite longer code but if I add code to open existing file and run parsing over it I can observe logs. Can anybody clarify it to me? Thanks in advance!

    opened by osmial 4
  • Error when compiling for Android

    Error when compiling for Android

    I was able to compile and run svgpp succesfully on Mac OS Sierra, but now that I'm trying to compile the library for Android, I can't get past the following error:

    FAILED: : && /Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++  -target mips64el-none-linux-android -gcc-toolchain /Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64 --sysroot=/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-mips64 -fPIC -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -std=c++11 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -std=c++11 -pthread -std=c++11 -frtti -fexceptions -ljnigraphics -Wno-format-security -v -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info  -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/mips64/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/Vectorizer.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/StbImpex.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/SvgImpex.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/Simplify.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/RDP/simplifyPath.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/Util.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/gradient.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/clip_buffer.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/filter.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/stb.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/parser_rapidxml_ns.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/agg/agg_curves.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/agg/agg_trans_affine.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/agg/agg_vcgen_dash.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/agg/agg_vcgen_stroke.cpp.o  -llog -lm "/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/mips64/libc++_shared.so" && :
      Android clang version 3.8.256229  (based on LLVM 3.8.256229)
      Target: mips64el-none-linux-android
      Thread model: posix
      InstalledDir: /Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin
      Found candidate GCC installation: /Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/mips64el-linux-android/4.9.x
      Selected GCC installation: /Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/mips64el-linux-android/4.9.x
      Candidate multilib: .;
      Selected multilib: .;
       "/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/mips64el-linux-android/4.9.x/../../../../mips64el-linux-android/bin/ld" --sysroot=/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-mips64 --sysroot=/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-mips64 --eh-frame-hdr -m elf64ltsmip -shared -o ../../../../build/intermediates/cmake/debug/obj/mips64/libnative-lib.so /Library/Android/sdk/ndk-bundle/platforms/android-21/arch-mips64/usr/lib/../lib64/crtbegin_so.o -LLibrary/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/mips64el-linux-android/4.9.x -L/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/mips64el-linux-android/4.9.x/../../../../mips64el-linux-android/lib/../lib64 -L/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-mips64/usr/lib/../lib64 -L/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/mips64el-linux-android/4.9.x/../../../../mips64el-linux-android/lib -L/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-mips64/usr/lib -ljnigraphics --build-id --warn-shared-textrel --fatal-warnings --no-undefined -z noexecstack -z relro -z now --build-id --warn-shared-textrel --fatal-warnings --no-undefined -z noexecstack -z relro -z now -soname libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/Vectorizer.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/StbImpex.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/SvgImpex.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/Simplify.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/RDP/simplifyPath.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/Util.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/gradient.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/clip_buffer.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/filter.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/stb.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/parser_rapidxml_ns.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/agg/agg_curves.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/agg/agg_trans_affine.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/agg/agg_vcgen_dash.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/agg/agg_vcgen_stroke.cpp.o -llog -lm /Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/mips64/libc++_shared.so -lstdc++ -lm -lgcc -ldl -lc -lgcc -ldl /Library/Android/sdk/ndk-bundle/platforms/android-21/arch-mips64/usr/lib/../lib64/crtend_so.o
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.2':
    /include/boost/optional/optional.hpp:76:(.text.startup+0xdc): relocation truncated to fit: R_MIPS_CALL16 against `boost::optional_ns::in_place_init_if_t::in_place_init_if_t(boost::optional_ns::in_place_init_if_t::init_tag)'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.3':
    /include/boost/spirit/home/support/unused.hpp:70:(.text.startup+0x130): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::unused_type::unused_type()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.7':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x290): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::terminal<boost::spirit::tag::hex>::terminal()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.10':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x398): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::terminal<boost::spirit::tag::ulong_>::terminal()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.12':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x448): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::terminal<boost::spirit::tag::short_>::terminal()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.13':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x4a0): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::terminal<boost::spirit::tag::long_>::terminal()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.14':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x4f8): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::terminal<boost::spirit::tag::int_>::terminal()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.16':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x5a8): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::terminal<boost::spirit::tag::long_long>::terminal()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.17':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x600): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::terminal<boost::spirit::tag::float_>::terminal()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.19':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x6b0): relocation truncated to fit: R_MIPS_CALL16 against `boost::spirit::terminal<boost::spirit::tag::long_double>::terminal()'
      CMakeFiles/native-lib.dir/src/main/cpp/svgpp_render/svgpp_parser_impl.cpp.o: In function `__cxx_global_var_init.20':
    /include/boost/spirit/home/support/common_terminals.hpp:89:(.text.startup+0x708): additional relocation overflows omitted from the output
      clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    

    I tried every permutation of flags and compiler settings that I found online but no luck so far.

    @svgpp it appears the error starts at svgpp_parser_impl.cpp and is related to boost::spirit::unused_type::unused_type(). Do you think that there is any way to go around this?

    I'm not a heavy user of boost, but just out of curiosity, do you think you could give some info on how boost is used in svgpp (which modules and why)? I see that svgpp has a ton of boost dependencies.

    opened by JaimeIvanCervantes 4
  • 在MFC中使用svgpp报错:error C3861: “min”: 找不到标识符

    在MFC中使用svgpp报错:error C3861: “min”: 找不到标识符

    您好,感谢您百忙之中查看该信息。 我在一个MFC工程中使用svgpp,在project中增加 NOMINMAX 。编译之后报错: 1>c:\program files (x86)\windows kits\8.1\include\um\gdiplustypes.h(475): error C3861: “min”: 找不到标识符 不知道怎么解决,请大神帮忙看看,谢谢!

    opened by minglplus 4
  • There are some problem with gdiplus.

    There are some problem with gdiplus.

    Hello. It is me again.

    I have encountered a new problem with gdiplus.

    I tried to draw a svgpath.

    M688 564Q631 523 555 487q56 -17 121.5 -31.5T804 432q8 -1 9.5 -4.5T813 417l-9 -34q-2 -11 -16 -8q-32 5 -71.5 13t-82 18t-85 21.5T468 450Q397 422 318 400.5T156 365q-15 -3 -19 7l-12 34q-2 5 1 9.5t9 6.5q70 14 132 30.5t118.5 35t109 41T599 577q17 9 15.5 15.5T597 599H199q-13 0 -13 13v35q0 12 13 12H631q78 0 95 -27.5T688 564ZM900 277t5 -3.5t5 -9.5V230q0 -5 -5 -9t-10 -4H45q-6 0 -10.5 4T30 230v34q0 6 4.5 9.5T45 277H432V383q0 14 14 14h41q14 0 14 -14V277H895q5 0 10 -3.5ZM502 158q-1 -5 -1 -10t-1 -10q3 -14 9 -26T523 89Q561 31 639.5 -13T827 -79q6 -2 7 -7t-1 -10l-16 -33q-2 -5 -5.5 -7.5T798 -137q-116 27 -201.5 78T469 57Q431 -6 350.5 -58T149 -143q-16 -4 -20 5l-14 37q-2 5 -0.5 11t8.5 8Q275 -41 354 22.5T436 161q0 12 12 12l46 -1q9 0 8 -14ZM611 782t0 -14V736q0 -15 -15 -15H333q-15 0 -15 15v32q0 14 15 14H596q15 0 15 -14Z

    i could draw it correctly with FillPath method of gdiplus.

    2

    But, in case of DrawPath method. There was some artifacts like below.

    default

    I painted red rectangles on the artifacts.

    Please help me.

    opened by Fogrunner 4
  • Very slow compilation (MSCV 12 up4 64bits)

    Very slow compilation (MSCV 12 up4 64bits)

    Hello,

    I am trying to use your library to load some SVG files under QT and post process them.

    The compilation is terribly slow. I mean I only include your main "svgpp/svgpp.hpp" in a single cpp file, where I bind everything into a Qobject, and that file takes something like 3 minutes to compile (Debug mode). Removing your dependencies, it only takes 2-3 seconds.

    Do you have any idea why it would be so slow? After compilation everything looks fine, and I can execute my code.

    opened by DrSParis 4
  • SVGPP not compatible with boost 1.71.0

    SVGPP not compatible with boost 1.71.0

    My project using svgpp fails to compile if boost is upgraded from 1.70 to 1.71.

    Errors occured:

    d:_proj\netlister\external\svgpp\include\svgpp\policy\value_events.hpp(22): error C2039: 'set': is not a member of 'LayoutContext::BaseContext'

    Compiler used: Visual Studio 2017

    opened by fhw72 3
  • I have a problem to draw shape.

    I have a problem to draw shape.

    I tried to draw svg path data to gdi+ bitmap. I referred to source code in demo for completing it.

    In result :

    1. It is a svg path of dashcharacter and works well. (It consists of lines)

    <path d="M616 440H66V621H616V440Z"/>

    1. It is a svg path of alphabet Ocharacter and does not work. (It consists of curves)

    <path d="M569 1085q215 0 356.5 -140T1067 547Q1067 234 914 104.5T569 -25Q368 -25 220 108T72 530q0 280 143 417.5T569 1085ZM569 123q154 0 234 114t80 300q0 199 -90.5 300T569 938Q432 938 344 835.5T256 530q0 -202 89.5 -304.5T569 123Z"/>

    Case number 2, nothing rendered. The paths which contain Bezier curve seem not to work.

    I made Context the same as PathStoragein demo source code.

    I have almost spent 5 days to fix it.

    Please help me, give me some piece of advice.

    opened by Fogrunner 3
  • Incorrect handling of transform in svg path

    Incorrect handling of transform in svg path

    When using a path with transformation the transformation is applied after the path is drawn. To demonstrate the issue use sample01b.cpp with the following SVG:

    TEXT(<svg xmlns="http://www.w3.org/2000/svg">)
    TEXT(<path d="M 80 80 A 45 45, 0, 0, 0, 125 125 L 125 80 Z" transform="scale(1.5)" />)
    TEXT(</svg>);
    

    The resultant call sequence is: path_move_to path_elliptical_arc_to path_line_to path_close_subpath transform_matrix

    When using that sample with it's original ellipse SVG the call sequence is as expected: transform_matrix path_move_to path_elliptical_arc_to path_elliptical_arc_to path_close_subpath

    This is with Git master, compiled with Visual Studio 2019.

    opened by sheetcam 1
  • Callbacks when loading a <use> element?

    Callbacks when loading a element?

    I am following the tutorial for resolving <use> elements in SVG.

    I think I have adequately filled in the blanks that this tutorial leaves for the reader, such as locating the referenced XML element, cloning this element and augmenting it with the attributes from the <use> element.

    I am now ready to load this cloned element:

    // variable "element" below is the referred-to element
    // which I have located in my XML document.
    
    auto clone = doc->clone_node(element);
    // add or overwrite x, y, width and height attributes on this clone
    ...
    document_traversal_t::load_referenced_element<
          referencing_element<tag::element::use_>,
          expected_elements<traits::reusable_elements>,
          processed_elements<
            boost::mpl::insert<processed_elements_t, tag::element::symbol>::type 
          >
        >::load(clone, *this);
    

    What would I expect to happen now? How can I test that the tutorial code now works?

    Using the XML used in your tutorial, I would expect the context to receive callbacks for attributes x, y, width and height. I think I have properly added these to the BaseContext in your tutorial, but I just don't seem to receive them.

    opened by mawnlower 3
  • When the width / height file attribute in the SVG is set to 0%, setsize exists set buffer [0] = 0x0, causing a null pointer reference.

    When the width / height file attribute in the SVG is set to 0%, setsize exists set buffer [0] = 0x0, causing a null pointer reference.

    Example: id^%000000,sig^%11,src^%000000,time^%16771,execs^%970,op^%flip1,pos^%62.zip Analyze:

    When SVG is wide and high attributes set to 0%, then the setsize () in svgpp_render.cpp: 334 is then called when calling ImageBuffer Buffer, and then set buffer_.resize to 0, and then execute ImageBuffer () After setting the generated buffer [0] to 0, the program continues to execute the m_rbuf-> width () in agg_pixfmt.rgba.h: 1646, which is incorrect, and the address pointing to the 0x0 is called when the function is called, thereby causing an empty pointer reference.

    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==2135593==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x0000006d1143 bp 0x7ffeb3c89c00 sp 0x7ffeb3c899c0 T0)
    ==2135593==The signal is caused by a READ memory access.
    ==2135593==Hint: address points to the zero page.
        #0 0x6d1143 in agg::row_accessor<unsigned char>::width() const /home/misift/fuzzing_svg/svgpp-1.3.0 (copy)/src/demo/render/../../../third_party/agg/include/agg_rendering_buffer.h:73:53
        #1 0x6d1143 in agg::pixfmt_alpha_blend_rgba<agg::blender_rgba<agg::rgba8T<agg::linear>, agg::order_rgba>, agg::row_accessor<unsigned char> >::width() const /home/misift/fuzzing_svg/svgpp-1.3.0 (copy)/src/demo/render/../../../third_party/agg/include/agg_pixfmt_rgba.h:1646:61
        #2 0x6d1143 in main /home/misift/fuzzing_svg/svgpp-1.3.0 (copy)/src/demo/render/svgpp_render.cpp:1709:60
        #3 0x7f2a6f521082 in __libc_start_main /build/glibc-KZwQYS/glibc-2.31/csu/../csu/libc-start.c:308:16
        #4 0x5f9a8d in _start (/home/misift/fuzzing_svg/svgpp-1.3.0 (copy)/src/build/bin/svgpp_agg_render+0x5f9a8d)
    
    AddressSanitizer can not provide additional info.
    SUMMARY: AddressSanitizer: SEGV /home/misift/fuzzing_svg/svgpp-1.3.0 (copy)/src/demo/render/../../../third_party/agg/include/agg_rendering_buffer.h:73:53 in agg::row_accessor<unsigned char>::width() const
    ==2135593==ABORTING
    
    

    credit:misift_Zero

    opened by M1sIft 1
  • Creating context factories for group elements

    Creating context factories for group elements

    I want to use a different context for path, use, and g elements. I followed sample01e.cpp, and got code like this:

    using processed_elements_t = boost::mpl::set<
    	tag::element::g,
    	tag::element::path,
    	tag::element::use_
    >::type;
    
    using processed_attributes_t = boost::mpl::set<
    	boost::mpl::pair<tag::element::path, tag::attribute::d>,
    	boost::mpl::pair<tag::element::path, tag::attribute::id>,
    	boost::mpl::pair<tag::element::path, tag::attribute::fill>,
    	boost::mpl::pair<tag::element::g, tag::attribute::id>,
    	boost::mpl::pair<tag::element::use_, tag::attribute::xlink::href>,
    	boost::mpl::pair<tag::element::use_, tag::attribute::transform>
    >::type;
    
    using color_t = int;
    
    struct BaseContext {
    	BaseContext(const BaseContext &parent) { }
    	virtual void on_exit_element() { }
    };
    
    struct PathContext: public BaseContext {
    	PathContext(const BaseContext &parent): BaseContext { parent } { }
    	void path_move_to(double x, double y, tag::coordinate::absolute) { }
    	void path_line_to(double x, double y, tag::coordinate::absolute) { }
    	void path_cubic_bezier_to(
    		double x1, double y1,
    		double x2, double y2,
    		double x3, double y3,
    		tag::coordinate::absolute) { }
    	void path_quadratic_bezier_to(
    		double x1, double y1,
    		double x, double y,
    		tag::coordinate::absolute) { }
    	void path_elliptical_arc_to(
    		double rx, double ry, double x_axis_rotation,
    		bool large_arc_flag, bool sweep_flag,
    		double x, double y,
    	tag::coordinate::absolute) { }
    	void path_close_subpath() { }
    	void path_exit() { }
    	void set(tag::attribute::id, const boost::iterator_range<const char*> val) { }
    	void on_exit_element() override { }
    	void set(tag::attribute::fill, color_t color, tag::skip_icc_color = tag::skip_icc_color()) { }
    	void set(tag::attribute::fill, tag::value::none) {}
    	void set(tag::attribute::fill, tag::value::currentColor) {}
    	template<class IRI>
    	void set(tag::attribute::fill tag, IRI const & iri) {}
    	template<class IRI>
    	void set(tag::attribute::fill tag, tag::iri_fragment, IRI const & fragment) {}
    	template<class IRI>
    	void set(tag::attribute::fill tag, IRI const &, tag::value::none val) {}
    	template<class IRI>
    	void set(tag::attribute::fill tag, tag::iri_fragment, IRI const & fragment, tag::value::none val) {}
    	template<class IRI>
    	void set(tag::attribute::fill tag, IRI const &, tag::value::currentColor val) {}
    	template<class IRI>
    	void set(tag::attribute::fill tag, tag::iri_fragment, IRI const & fragment, tag::value::currentColor val) {}
    	template<class IRI>
    	void set(tag::attribute::fill tag, IRI const &, color_t val, tag::skip_icc_color = tag::skip_icc_color()) {}
    	template<class IRI>
    	void set(tag::attribute::fill tag, tag::iri_fragment, IRI const & fragment, color_t val, tag::skip_icc_color = tag::skip_icc_color()) {}
    };
    
    struct GroupContext: public BaseContext {
    	GroupContext(const BaseContext &parent): BaseContext { parent } { }
    	void on_exit_element() override { }
    	void set(tag::attribute::id, const boost::iterator_range<const char*> val) { }
    };
    
    struct UseContext: public BaseContext {
    	UseContext(const BaseContext &parent):
    		BaseContext { parent } { }
    	template<class IRI>
    	void set(tag::attribute::xlink::href, tag::iri_fragment, const IRI &fragment) { }
    	template<class IRI>
    	void set(tag::attribute::xlink::href, const IRI &fragment) { 
    		std::cerr << "External references aren't supported\n"; 
    	}
    	void set(tag::attribute::x, double val) { }
    	void set(tag::attribute::y, double val) { }
    	void set(tag::attribute::width, double val) { }
    	void set(tag::attribute::height, double val) { }
    	void transform_matrix(const boost::array<double, 6> &matrix) { }
    	void on_exit_element() override { }
    };
    
    struct ChildContextFactories {
    	template<class ParentContext, class ElementTag, class Enable = void> 
    	struct apply {
    		typedef factory::context::on_stack<BaseContext> type;
    	};
    };
    
    template<>
    struct ChildContextFactories::apply<BaseContext, tag::element::path> {
    	typedef factory::context::on_stack<PathContext> type;
    };
    
    template<>
    struct ChildContextFactories::apply<BaseContext, tag::element::g> {
    	typedef factory::context::on_stack<GroupContext> type;
    };
    
    template<>
    struct ChildContextFactories::apply<BaseContext, tag::element::use_> {
    	typedef factory::context::on_stack<UseContext> type;
    };
    
    using document_traversal_t = document_traversal<
    	processed_elements<processed_elements_t>,
    	processed_attributes<processed_attributes_t>,
    	context_factories<ChildContextFactories>
    >;
    

    However, this won't compile and gives many errors similar to:

    include/svgpp/policy/value_events.hpp:23:13: error: ‘struct BaseContext’ has no member named ‘set’
       23 |     context.set(tag, args...);
          |     ~~~~~~~~^~~
    

    I found that if I also include:

    template<class ElementTag>
    struct ChildContextFactories::apply<GroupContext, ElementTag, void>: 
    	ChildContextFactories::apply<BaseContext, ElementTag> { };
    

    Then the code will compile, but the problem is only one GroupContext is ever created, rather than a different GroupContext for each g element in the SVG.

    I would like to know why context factories for g elements behave differently than for the path and use elements.

    opened by cglzhng 1
Releases(v1.3.0)
Owner
Oleg Maximenko
Oleg Maximenko
NanoSVG is a simple stupid single-header-file SVG parse

This project is not actively maintained. Nano SVG Parser NanoSVG is a simple stupid single-header-file SVG parse.

Mikko Mononen 1.4k Dec 31, 2022
This library provides a cross-platform image loading library in C11 for projects based on our foundation library

Image Library - Public Domain This library provides a cross-platform image loading library in C11 for projects based on our foundation library.

Mattias Jansson 1 Jan 29, 2022
PillowResize library is a C++ porting of the resize method from the Pillow python library.

Pillow Resize Table of Contents Description Compilation Installation Usage Description PillowResize library is a C++ porting of the resize method from

Zuru Tech 47 Nov 17, 2022
GD Graphics Library

GD Graphics (Draw) Library GD is an open source code library for the dynamic creation of images by programmers. GD is written in C, and "wrappers" are

GD Graphics Library 777 Dec 28, 2022
An open source library for face detection in images. The face detection speed can reach 1000FPS.

libfacedetection This is an open source library for CNN-based face detection in images. The CNN model has been converted to static variables in C sour

Shiqi Yu 11.4k Jan 8, 2023
A fast image processing library with low memory needs.

libvips : an image processing library Introduction libvips is a demand-driven, horizontally threaded image processing library. Compared to similar lib

libvips 26 Nov 10, 2022
C++ image processing and machine learning library with using of SIMD: SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX-512, VMX(Altivec) and VSX(Power7), NEON for ARM.

Introduction The Simd Library is a free open source image processing and machine learning library, designed for C and C++ programmers. It provides man

Ihar Yermalayeu 1.7k Jan 5, 2023
Tiny ISO-compliant C++ EXIF and XMP parsing library for JPEG.

TinyEXIF: Tiny ISO-compliant C++ EXIF and XMP parsing library for JPEG Introduction TinyEXIF is a tiny, lightweight C++ library for parsing the metada

cDc 84 Dec 18, 2022
Video++, a C++14 high performance video and image processing library.

Video++ Video++ is a video and image processing library taking advantage of the C++14 standard to ease the writing of fast video and image processing

Matthieu Garrigues 692 Dec 28, 2022
a generic C++ library for image analysis

VIGRA Computer Vision Library Copyright 1998-2013 by Ullrich Koethe This file is part of the VIGRA computer vision library. You may use,

Ullrich Koethe 378 Dec 30, 2022
A C++ library for Background Matting

libovmatting A C++ library for Background Matting using openvino and deep learning models. Now support models such as BackgroundMattingV2, MODNet. App

null 45 Nov 22, 2022
A file dialog library for Dear ImGui

ImFileDialog A simple file dialog library for Dear ImGui. This library supports favorites, actual Windows icons, image previews, zooming in, etc... DI

dfranx 398 Jan 3, 2023
Intel® Open Image Denoise library

Intel Open Image Denoise is an open source library of high-performance, high-quality denoising filters for images rendered with ray tracing

Intel® Open Image Denoise 1.3k Dec 28, 2022
Arduino PNG image decoder library

An 'embedded-friendly' (aka Arduino) PNG image decoding library

Larry Bank 102 Jan 6, 2023
ZT is a zig-contained library that automatically compiles+links ImGui, OpenGL, and GLFW into typed packages.

ZT is a zig-contained library that automatically compiles+links ImGui, OpenGL, and GLFW into typed packages. By zig contained I mean that ZT is intend

null 90 Jan 1, 2023
libvot - A C++11 multi-thread library for image retrieval

libvot is a fast implementation of vocabulary tree, which is an algorithm widely used in image retrieval and computer vision. It usually comprises three components to build a image retrieval system using vocabulary tree: build a k-means tree using sift descriptors from images, register images into the database, query images against the database. I

Tianwei Shen 174 Dec 22, 2022
ppl.cv is a high-performance image processing library of openPPL supporting x86 and cuda platforms.

ppl.cv is a high-performance image processing library of openPPL supporting x86 and cuda platforms.

null 366 Dec 30, 2022
An 'embedded-friendly' (aka Arduino) JPEG image encoding library

Starting in the late 80's I wrote my own imaging codecs for the existing standards (CCITT G3/G4 was the first). I soon added GIF, JPEG and not long after that, the PNG specification was ratified. All of this code was "clean room" - written just from the specification. I used my imaging library in many projects and products over the years and recently decided that some of my codecs could get a new lease on life as open source, embedded-friendly libraries for microcontrollers.

Larry Bank 38 Dec 30, 2022