Home > Net >  Ask: how c # the 8-bit grayscale convert byte [] type?
Ask: how c # the 8-bit grayscale convert byte [] type?

Time:11-26

I ask, how to put the 8-bit grayscale convert byte [] type ah, I use the following this code, the conversion of less to

I use the console output BMP PixelFormat, type of Format8bppIndexed
 
Public static byte [] GetByteData Bitmap (BMP)
{
BitmapData bmpdata=https://bbs.csdn.net/topics/null;
Bmpdata=https://bbs.csdn.net/topics/bmp.LockBits (new Rectangle (0, 0, BMP. Width, BMP, Height), ImageLockMode. ReadOnly, BMP. PixelFormat);
Int numbytes=bmpdata. Stride * BMP. Height;
Byte [] bytedata=https://bbs.csdn.net/topics/new byte [numbytes];
IntPtr PTR=bmpdata. Scan0;

Marshal. Copy (PTR, bytedata, 0, numbytes);

Return bytedata;
}
  •  Tags:  
  • C#
  • Related