Determine if an image is opaque or transparent
I don't know how good the C# compiler and runtime optimize this code out of the box, so here is what I would try:


Load bitmap.Width, bitmap.Height and bitmapData.Stride into local variables.
Swap the two for loops, making x the inner loop. Memory accesses are now linear instead of jumping around (to see this, print the array index in your current code).


Side node: You should check whether your code works correctly on big-endian platforms. The + 3 looks suspicious. You could use a uint * instead of the byte * and test the pixel value like this: (p[x + stride * y] &gt;= 0xFF000000.