memononen / nanosvg

Simple stupid SVG parser
zlib License
1.71k stars 363 forks source link

added support for fillOpacity for gradients #137

Open hor-net opened 6 years ago

neuroticflux commented 5 years ago

Could we get a review on this?

perepujal commented 5 years ago

I've just merged into my local copy and found that it crashes at least on one file trying to access shape->fill.gradient->nstops when shape->fill.gradient is NULL. The file that makes it crash is at https://sourceforge.net/p/tuxpaint/tuxpaint-stamps/ci/master/tree/stamps/clothes/bikini.svg Maybe start with an else so the code doesn't gets called unconditionally?


        else
          for (int i = 0; i < shape->fill.gradient->nstops; i++) {
            unsigned int alpha = (shape->fill.gradient->stops[i].color >> 24) * attr->fillOpacity;
            shape->fill.gradient->stops[i].color &=0x00FFFFFF;
            shape->fill.gradient->stops[i].color |= alpha << 24;
          }