static Bitmap To8bpp(Bitmap original) { int width = original.Width; int height = original.Height; Bitmap result = new Bitmap(width, height); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Color color = original.GetPixel(x, y); result.SetPixel(x, y, color); } } Rectangle rectangle = new Rectangle(0, 0, width, height); PixelFormat pixelFormat = PixelFormat.Format8bppIndexed; BitmapData bitmapData = result.LockBits(rectangle, ImageLockMode.ReadOnly, result.PixelFormat); Bitmap bitmap = new Bitmap(width * 4, height, bitmapData.Stride, pixelFormat, bitmapData.Scan0); result.UnlockBits(bitmapData); return bitmap; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)