Fastest way to clamp an integer to the range 0-255
Try
 int x=n&gt;255?255:n;
 ... x&lt;0?0:x ...

I'd expect this to produce something like:
 mov     ebx, 255
 mov     eax, n
 cmp     eax, ebx
 cmovg   eax, ebx ; conditional mov instruction
 test    eax, eax
 mov     ebx, 0
 cmovl   eax, ebx

If you are using MSVC SIX, you may not get the conditional move instruction. Try switching to a modern version of visual studio.