@polygon7

Why the instead of ?

This line

unsigned long imageSize = (image.GetWidth() * image.GetHeight()) << 2;

"<<" is shifting bits operator (shift left, SHL in assembly). SHL can be used for multiply by power of two (SHR, shift right for dividing by power of two).

x*2 == x <<1, x*4 == x <<2 ...

Bit shifting usually is faster then normal multiply.