-
[MASM] Solarize Image
This is a filter I've come up with..
Code:
; Solarize
Solarize PROTO :DWORD,:DWORD,:DWORD
Solarize proc uses edi esi hDC:DWORD,imageX:DWORD,imageY:DWORD
LOCAL rect:RECT
LOCAL red:DWORD
LOCAL green:DWORD
LOCAL blue:DWORD
LOCAL red_res:DWORD
LOCAL green_res:DWORD
LOCAL blue_res:DWORD
mov edi,imageX
dec edi
mov esi,imageY
dec esi
.REPEAT
.REPEAT
invoke GetPixel,hDC,edi,esi
; This gets only the Alpha value back in EAX discarding the rest
;and eax,0FF000000h
;shr eax,24
mov edx,eax
; RED
and eax,00FF0000h
shr eax,16
mov red,eax
mov red_res,eax
mov eax,edx
; BLUE
and eax,00FF0000h
mov blue,eax
mov blue_res,eax
mov eax,edx
; GREEN
and eax,0000FF00h
mov green,eax
mov green_res,eax
.if (red<128) || (red>255)
mov red,255
mov eax,red
sub eax,red_res
mov red,eax
.endif
.if (green<128) || (green>255)
mov green,255
mov eax,green
sub eax,green_res
mov green,eax
.endif
.if (blue<128) || (blue>255)
mov blue,255
mov eax,blue
sub eax,blue_res
mov blue,eax
.endif
mov ecx,red
add ecx,green
add ecx,blue
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
Solarize endp
If you compile it into a DLL (like I have) it can be used in VB :D
Phreak