UNPKG

nativescript-image-black-and-white

Version:

A NativeScript plugin to apply a black-and-white filter on Image.

27 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ImageBlackAndWhite = (function () { function ImageBlackAndWhite() { } ImageBlackAndWhite.prototype.blackAndWhite = function (img) { if (img.isLoading) { console.log('WARNING: Cannot apply filter if image is not yet loaded.'); } var matrix = new android.graphics.ColorMatrix(); matrix.setSaturation(0); var filter = new android.graphics.ColorMatrixColorFilter(matrix); img.android.setColorFilter(filter); }; ImageBlackAndWhite.prototype.clearFilter = function (img) { if (img.isLoading) { console.log('WARNING: Cannot remove filter if image is not yet loaded.'); } var imageView = img.android; if (imageView) { imageView.clearColorFilter(); } }; return ImageBlackAndWhite; }()); exports.ImageBlackAndWhite = ImageBlackAndWhite; //# sourceMappingURL=image-black-and-white.android.js.map