Is there a better way? Please note that I’m not using fixed because I need to scan through the buffer data.
GCHandle pinned1 = GCHandle.Alloc(Pic1, GCHandleType.Pinned);
IntPtr ptr1 = pinned1.AddrOfPinnedObject();
byte* p1 = (byte*)ptr1.ToPointer();
//...
//...
//...
byte a=*p1;
p1++;
//...
//...
pinned1.Free();
Yes, there is a better way: use
fixed.You can simply assign the pointer to another variable and perform pointer arithmetic on that: