/// <summary>
        /// Convert an image to grayscale.
        /// </summary>
        /// <param name="src">The image buffer (RGBA pixels).</param>
        /// <param name="srcPos">Initial position on the source buffer.</param>
        /// <param name="width">The width of the image.</param>
        /// <param name="height">The height of the image.</param>
        /// <param name="stride">The distance, in bytes, between rows of the image buffer.</param>
        static void GrayscaleImage(byte[] src, int srcPos, int width, int height, int stride)
        {
            int pos = srcPos;

            for (int y = 0; y < height; y++, pos += stride - width * 4)
            {
                for (int x = 0; x < width; x++, pos += 4)
                {
                    ColorRGBA srcColor       = ColorRGBA.Read(src, pos);
                    ColorRGBA grayscaleColor = ColorRGBA.FromIntensityAlpha(srcColor.Intensity(), srcColor.a);
                    grayscaleColor.Write(src, pos);
                }
            }
        }
예제 #2
0
 public static ColorRGBA IA4ToColor(byte v)
 {
     return(ColorRGBA.FromIntensityAlpha(Bits4To8[v & 0x0F], Bits4To8[v >> 4]));
 }
예제 #3
0
 public static ColorRGBA I8ToColor(byte v)
 {
     return(ColorRGBA.FromIntensityAlpha(v, 0xFF));
 }
예제 #4
0
 public static ColorRGBA I4ToColor(byte v)
 {
     return(ColorRGBA.FromIntensityAlpha(Bits4To8[v], 0xFF));
 }