Night - Day Filter

BlitzPlus Forums/BlitzPlus Programming/Night - Day Filter

Here is a realtime function to draw lighten or darken images( it may works but not tested ) :

function DrawLightenImage(img,x,y,light#,dst=0)
w=ImageWidth()
h=ImageHeight()

if dst=0 then dst=GraphicsBuffer()

LockBuffer(dst)
lockbuffer(imageBuffer(img))
for j=0 to h-1
for i=0 to w-1
p=ReadPixelFast(i,j,ImageBuffer(img))
if p<>$FF000000 then
red=p shr 16 and 255
green=p shr 8 and 255
blue=p and 255
red=float(red)*light
green=float(green)*light
blue=float(blue)*light
p=blue Or (green Shl 8) Or (red Shl 16) Or (255 Shl 24)
WritePixelFast(x+i,y+j,p,dst)
endif
next
next
unlockbuffer(ImageBuffer(img))
UnlockBuffer(dst)
end function