Can someone explain the BitmapData.Scan0 property?
Posted on 2006-03-31
This property is a strange one, I made two copies of a bitmap file, included both files as resources, and loaded the resources into bitmap and bitmapdata objects as follows:
Dim b As New Bitmap(My.Resources.pic1) ' from bmp file pic1
Dim b2 As New Bitmap(My.Resources.pic2) ' from exact copy of pic1 picture file
Dim r As New Rectangle(0, 0, b.Width, b.Height)
Dim bd As BitmapData
bd = b.LockBits(r, ImageLockMode.ReadOnly, b.PixelFormat)
Dim bd2 As BitmapData
bd2 = b2.LockBits(r, ImageLockMode.ReadOnly, b2.PixelFormat)
I was trying to cheat and do an Equals on the two bitmapdata objects to see if they were the same picture, but they turn out to be unequal. Putting a breakpoint after the above, code,I see that the only difference is the Scan0 property, for which one has a value of 62935008 and the other has a value of 62944688. I guess I don't really understand what this property is, and how they ended up different. MSDN says Scan0:
"Gets or sets the address of the first pixel data in the bitmap. This can also be thought of as the first scan line in the bitmap."
I read this and assumed that it was an address relative to the first byte of the object, maybe a header length or something. It would seem weird if it was its own actual location in memory... does anyone know for sure?