Problems | pointers
Today, the algorithm was found in the past in C + + with the UINT pointer access to 32-bit ARGB bitmap, each offset is exactly one pixel, so direct use of "+ +" instead of "+ + 4". Similarly, when directly using a coordinate access, you should use "I * STRIDE/4 + j" instead of "I * stride + j". But when you move to C # code, you find that if you use the same UINT pointer to access the bitmap, there may not be a problem when stride equals width*4, and the problem will occur once the Noffset is not 0. But the second bug didn't prove to happen every time. Find time to correct the code, in the absence of improved algorithm, it is recommended to use the byte type pointer for bitmap access.
Article Source: Http://spaces.msn.com/sharkoo/Blog/cns!D8E832CE4545AF!153.entry
Add: When the lock locates all the stride=width*4, when the lock is part of the bitmap, stride will not be equal to width*4.