PDA

Click to See Complete Forum and Search --> : [MASM] GrayScale Image


chemicalNova
Jul 10th, 2004, 01:29 AM
This is a filter I've come up with:

; GrayScale Function

GrayScale proc uses edi esi hDC:DWORD,imageX:DWORD,imageY:DWORD

LOCAL rect:RECT
LOCAL red:DWORD
LOCAL green:DWORD
LOCAL blue:DWORD

mov edi,imageX
dec edi
mov esi,imageY
dec esi
.REPEAT
.REPEAT
invoke GetPixel,hDC,edi,esi

movzx ecx,al
mov red,ecx
shr eax,8
movzx ecx,al
mov green,ecx
shr eax,8
movzx ecx,al
mov blue,ecx

mov eax,66
imul red
mov ecx,eax

mov eax,129
imul green
add ecx,eax

mov eax,25
imul blue
add ecx,eax

add ecx,128
shr ecx,8
add ecx,16

xor eax,eax

mov al,cl
shl eax,8
mov al,cl
shl eax,8
mov al,cl

invoke SetPixelV,hDC,edi,esi,eax
dec esi
.UNTIL SIGN?
mov esi,imageY
dec esi
dec edi
.UNTIL SIGN?
ret
GrayScale endp

If you compile it into a DLL you can use it in VB..

Phreak