Click here to Skip to main content
15,794,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good morning to everyone. Is it possible to copy the pixel values in the image to a array? If possible, how?

1 solution

Lock the bitmap in memory, then copy all values from Scan0 on:

BitmapData data = bmp.LockBits(
        new Rectangle(0,0,bmp.Width,bmp.Height),
int length = data.Stride*bmp.Height;
byte[] stream = new byte[length];
Marshal.Copy(data.Scan0, stream, 0, length);

Found here.[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900