Closed fdncred closed 5 years ago
Very Dangerous! If you do something with pix over all_functions the byte() will Be not updated! I fix the getdata. This should be the safe way.
Marshal.PtrToStructure(Pointer, Values) in the first line stands for update the values from memory for exactly this case. you can try with sarray to see what i mean: Create Sarray Object with ("1","2","3") Add "4" to the Array via _all and then look at the old Object (if marshal ... removed) you see exactly 1,2 and 3 ... not the 4. the same is with pix if you work with a backing property.
I understand Marshal.PtrToStructure(). My point is that if you try and use the data property and iterate through it in a for loop, then every iteration will cause the entire image to be re-marshalled, which is a waste of time and terribly inefficient. For that reason, I'm keeping my backing property and if I want to make changes I can always use the Set on the data property. So, until the data property is fixed/changed this should stay open.
Created additionally a DataStatic Property - which is the data of the first access if pix is changed (unsure if this ever occurs) this data stays old. (and will be also destroyed if pix is destroyed). for your cases its exactly what you need i think
I had to change this property because if you iterate data it takes way too long.
New Code:
It now has a backing property so each time you loop on the data property it doesn't try to marshal the entire data pointer.