NativeScript / nativescript-fresco

This repository holds the NativeScript plugin that exposes the functionality of the Fresco image library to NativeScript developers.
Apache License 2.0
53 stars 23 forks source link

feat: add resizing and downsampling feature #72

Closed mintyweazel closed 6 years ago

mintyweazel commented 6 years ago

This is an implementation of #70 . Please check here about the difference between the two features.

To enable resizing feature, you will have to set decodeWidth,decodeHeight attributes to FrescoDrawee.

    <FrescoDrawee
        width="100"
        height="100"
        imageUri="<YOUR IMAGE URL>"
        decodeWidth="100"
        decodeHeight="100"
    >
    </FrescoDrawee>

To enable downsampling feature, besides the settings for resizing, you will have to add a custom setting when initializing Fresco in the launch event.

if (application.android) {
    application.on("launch", () => {
        // enable donwsampling
        fresco.initialize({ isDownsampleEnabled: true });

        // if not needed, you can initialize Fresco in the same manner as it was
        // fresco.initialize();
    });
}

If the value isDownsampleEnabled is set to false or not set, downsampling feature will not be activated.