Afternoon, bitRake.
Cheers,
Scronty
shr eax, 16
isn't it?:grin:
Cheers,
Scronty
Scronty, yes. Thanks, I was a little quick on my responses.
Could the following code be smaller and faster?
Thanks.
Thanks.
GetLuminosity proc color:COLORREF ; the algorithm is (((rgbMax+rgbMin) * HLSMAX) + RGBMAX ) / (2*RGBMAX);
HLSMAX equ 240
RGBMAX equ 255
mov edx, GetGValue(color)
mov ecx, GetBValue(color)
mov eax, GetRValue(color)
max eax, <ecx, edx> ; the maximum value is returned to eax
min ecx, <eax, edx> ; the minimum value is returned to ecx
add eax, ecx ; rgbmax + rgbmin
mov ecx, HLSMAX
mul ecx
add eax, RGBMAX ; we ignore the edx part since the the result is within 32 bits
shr eax, 1
xor edx,edx
mov cx, RGBMAX
div cx
ret
GetLuminosity endp