Beispiel #1
0
        /// <summary>
        /// Gets Color at pixel location of BitmapSource
        /// <remarks>This is an extension method provided by <seealso cref="BitmapEx"/></remarks>
        /// </summary>
        public static Color GetPixelColorAt(this BitmapSource bitmap, int x, int y)
        {
            int index  = ((y - 1) * bitmap.PixelWidth) + x;
            var pixels = bitmap.GetPixels();
            var color  = GetPixelColor(index, pixels);

            return(color);
        }
Beispiel #2
0
        /// <summary>
        /// Checks if the BitmapSource is empty (all pixels are blank)
        /// </summary>
        public static bool IsEmpty(this BitmapSource bitmap)
        {
            var pixels = bitmap.GetPixels();

            foreach (var pixel in pixels)
            {
                if (pixel != 0)
                {
                    return(false);
                }
            }
            return(true);
        }