Esempio n. 1
0
        public static SKImage ApplyMatrix(SKImage Source, float[] mat)
        {
            SKRectI irect  = new SKRectI((int)0, (int)0, Source.Width, Source.Height);
            var     result = Source.ApplyImageFilter(SKImageFilter.CreateColorFilter(SKColorFilter.CreateColorMatrix(mat)), irect, irect, out SKRectI active, out SKPoint activeclip);

            return(result);
        }
Esempio n. 2
0
        // Convert bitmap to grayscale and apply contrast to emphasize lines
        // For conversion SKColorFilter is used
        // However, SKColorFilter is usually set in SKPaint object and applied to canvas when drawn
        // To apply it to the bitmap, we have to convert bitmap to image because it's possible to apply filters to images
        SKBitmap ConvertBitmapToGray(SKBitmap bitmap, float contr = contrast)
        {
            SKImage       image       = SKImage.FromBitmap(bitmap);
            SKImageFilter imagefilter = SKImageFilter.CreateColorFilter(SKColorFilter.CreateHighContrast(true, SKHighContrastConfigInvertStyle.NoInvert, contrast));
            SKRectI       rectout     = new SKRectI();
            SKPoint       pointout    = new SKPoint();

            image = image.ApplyImageFilter(imagefilter, new SKRectI(0, 0, image.Width, image.Height), new SKRectI(0, 0, image.Width, image.Height), out rectout, out pointout);

            return(SKBitmap.FromImage(image));
        }