Dim im
Set im = CreateObject("ActiveImage.Images.1")
'im.CreateImagePalette 300,400
im.SetImageType 1
im.ReadFromFile "C:\AI\rose.jpg"
im.ConvertToPaletteNoAlpha
width = im.GetWidth
height = im.GetHeight
colorbk_r = 0
colorbk_g = 0
colorbk_b = 0
Threshold = 72
For x = 0 to width
for y = 0 to height
r = im.GetPixelRed(x,y)
g = im.GetPixelGreen(x,y)
b = im.GetPixelBlue(x,y)
if r < Threshold then
im.SetColor colorbk_r, colorbk_g, colorbk_b
im.SetPixel x,y
end if
next
next
im.SetColor colorbk_r, colorbk_g, colorbk_b
im.SetTransparent 1
im.SetSaveAlpha 0
im.SetImageType 3
im.WriteToFile "C:\AI\Threshold.gif"
im.SetImageType 0
im.WriteToFile "C:\AI\Threshold.png"
im.DestroyImage
Set im = Nothing
|