Re-shuffle SetThreadName function to match MSDN documentation
Change loop type
Avoid overflow when calculating number of pixels in an image

CID 1041131, 1041132