Copying bytes from Bitmap to byte array and back with Marshall.Copy doesn't work right
问题 I want to copy bytes with Marshall.Copy. My code work, but bytes is strange for me. I think, I got indexes not real bytes. If this compute and save back, I got different colors in image with lot bigger byte size (image size is same). Bitmap bmp = new Bitmap(imagepath); Width = bmp.Width; Height = bmp.Height; byte[] data; BitmapData bdata; switch (bmp.PixelFormat) { case PixelFormat.Format8bppIndexed: { data = new byte[Width * Height]; bdata = bmp.LockBits(new Rectangle(0, 0, Width, Height)