Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is BitmapData.reserved?

BitmapData has a property called Reserved, which returns a 32-bit signed integer. Microsoft's documentation says not to use this property. If we shouldn't use it; then why is it there? What exactly is it for?

like image 253
bbosak Avatar asked Feb 23 '23 20:02

bbosak


2 Answers

Reserved fields and properties can have a variety of uses. One fairly common usage is to allow for the possibility that more sophisticated types of BitmapData may in future need to store some type of information for which the present structure makes no provision. If nobody has used the Reserved field for anything, future implementations could use that field to hold a pointer or handle to another structure containing additional information.

like image 104
supercat Avatar answered Mar 07 '23 21:03

supercat


Interesting, that's a bug. It is actually an IntPtr, you can tell from the native declaration, GdiPlusImaging.h header file in the SDK (c:\program files\microsoft sdks\windows\v6.0a\include directory for VS2008). The bug doesn't byte because GDI+ creates the instance of it.

Which makes it likely that the field stores a pointer or a handle. I would guess at the memory mapped file object handle. Cheaper to store it in the client state object over having to maintain a dictionary to find it back in the UnlockBits() function. Don't mess with it.

like image 37
Hans Passant Avatar answered Mar 07 '23 21:03

Hans Passant