I have an array of raw pixel data I would like to convert it into 8 bpp bitmap. Public statement Bitmap bytegrebmatmap (Byte [] rawbates, int width, intensity height) {bitmap bitmap = new bitmap (width, height, pixel format. Format 8 bPP unregistered); Bitmapdata bitmapdata = bitmap Lockbits (new rectangle (0, 0, width, height), image lockcomd.site only, bitmap pixel format); Marshall Coppie (Rawbeats, 0, Bitmapadata Scan 0, Rawbeats lang); Bitmap.UnlockBits (BitmapData); Return bitmap; }
Bitmap resembles a color image instead of grayscale.
Try adding it before returning the bitmap:
For (int c = 0; c & lt; bitmap.Palette.Entries.Length; c ++) bitmap.Palette.Entries [c] = color .FromArgb (c, c, c);
This will create a specific grayscale palette.
No comments:
Post a Comment