Пример #1
0
        public Pixel GetPixel(int x, int y)
        {
            switch (bitmap.PixelFormat)
            {
            case PixelFormat.Format24bppRgb:
                PixelData24 pixel24 = *PixelAt24(x, y);
                return(new Pixel(255, pixel24.red, pixel24.green, pixel24.blue));

            case PixelFormat.Format32bppArgb:
                PixelData32 pixel32 = *PixelAt32(x, y);
                return(new Pixel(pixel32.alpha, pixel32.red, pixel32.green, pixel32.blue));

            default:
                throw new NotSupportedException();
            }
        }
Пример #2
0
        public void SetPixel(int x, int y, byte alpha, byte red, byte green, byte blue)
        {
            switch (bitmap.PixelFormat)
            {
            case PixelFormat.Format24bppRgb:
                PixelData24 *pixel24 = PixelAt24(x, y);
                *            pixel24 = new PixelData24(red, green, blue);
                break;

            case PixelFormat.Format32bppArgb:
                PixelData32 *pixel32 = PixelAt32(x, y);
                *            pixel32 = new PixelData32(alpha, red, green, blue);
                break;

            default:
                throw new NotSupportedException();
            }
        }