Ejemplo n.º 1
0
        public static void ShadeImage(IndexedImage image, int argb, IndexedImage maskImage = null)
        {
            Debug.Assert(maskImage == null || maskImage.Size.Equals(image.Size), "maskImage should have same size as image");

            for (int i = 0; i < image.Pixels.Length; i++)
            {
                var shadeArgb = maskImage != null?ColorBytes.ShadeColor(argb, maskImage.Pixels[i]) : argb;

                image.Pixels[i] = ColorBytes.ShadeColor(image.Pixels[i], shadeArgb);
            }
        }
Ejemplo n.º 2
0
 static void ColorCursorImage(IndexedImage image, int argb)
 {
     int[] pixels;
     using (image.LockPixels(out pixels))
     {
         Parallel.For(0, pixels.Length,
                      index =>
         {
             var pixelArgb = pixels[index];
             var a         = pixelArgb.Alpha();
             if (a != 0)                             // Skip transparent
             {
                 var r = pixelArgb.Red();
                 var g = pixelArgb.Green();
                 var b = pixelArgb.Blue();
                 if (Math.Abs(r - g) + Math.Abs(g - b) + Math.Abs(b - r) <= 12)                                 // Close to grey colors
                 {
                     pixels[index] = ColorBytes.ShadeColor(pixelArgb, argb);
                 }
             }
         });
     }
 }