facebook/fresco

SVGs - ScaleTypes and Color Filters not working

Open

#2,298 opened on Feb 28, 2019

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Java (17,072 stars) (3,750 forks)batch import
enhancementgood first issuehelp wantedstarter-task

Description

Description

I followed this code example: https://github.com/facebook/fresco/tree/master/samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/imageformat/svg

to implement SVGs in my Android app along with the help of AndroidSVG 1.3

I'm experiencing the following:

  1. The scaling of image in my DraweeViews are all messed up. The SVGs are either cut off on the left side or appear in the top left corner. I've tried multiple ScaleTypes.
    • Using getHierarchy().setActualImageScaleType
  2. Depending on the device the SVGs can either be big or small.
  3. Color filters aren't working for me on the SVGs. (getHierarchy().setActualImageColorFilter)
  4. On API 21 & 22, SVGs don't appear at all

This is how I initialize Fresco:

ImageFormat.FormatChecker svgFormatChecker = new FrescoSvgImageFormatChecker();
        ImageDecoder svgDecoder = new FrescoSvgDecoder();
        ImageDecoderConfig svgDecoderConfig = new ImageDecoderConfig.Builder()
                .addDecodingCapability(
                        FrescoSvgImageFormatChecker.Companion.getSvgFormat(),
                        svgFormatChecker,
                        svgDecoder)
                .build();

        ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
                .setImageDecoderConfig(svgDecoderConfig)
                .setDownsampleEnabled(true)
                .build();

        DrawableFactory svgDrawableFactory = new FrescoSvgDrawableFactory();
        DraweeConfig draweeConfig = DraweeConfig.newBuilder()
                .addCustomDrawableFactory(svgDrawableFactory)
                .build();

fresco_svg_issue_1 fresco_svg_issue_2

  • Fresco version: 1.7.1
  • Platform version: Happens on every single device.

Contributor guide