Click here to Skip to main content
15,887,083 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?
Posted

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),
                ImageLockMode.WriteOnly,
                PixelFormat.Format24bppRgb);
int length = data.Stride*bmp.Height;
byte[] stream = new byte[length];
Marshal.Copy(data.Scan0, stream, 0, length);
bmp.UnlockBits(data);
bmp.Dispose();


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