[VBScript]
Set theObj = Server.CreateObject("ImageGlue7.Canvas")
theObj.DrawFile Server.MapPath("boat.gif"), ""
' white transparent with a little tolerance
theObj.Select "notcolor", "keycolor=0xFF,0xFF,0xFF
tolerance=10.0"
theObj.SaveAs Server.MapPath("alphaboat.png"), "alpha=true"
The code above draws the image mypic onto a canvas. It then
selects everything that is white and saves the completed image with
selection-as-alpha-channel into a png. The input and output images
are shown below.
boat.gif
alphaboat.png
[VBScript]
Set ca1 = Server.CreateObject("ImageGlue7.Canvas")
ca1.DrawFile Server.MapPath("boat.gif"), ""
' white transparent with a little tolerance
ca1.Select "notcolor", "keycolor=0xFF,0xFF,0xFF tolerance=10.0"
Set ca2 = CreateObject("ImageGlue7.Canvas")
ca2.Color = "red"
ca2.Width = ca1.Width
ca2.Height = ca1.Height
ca2.DrawCanvas ca1.Image, "Mode=Transparent"
ca2.SaveAs Server.MapPath("redboat.jpg"), ""
The code above selects all the white - or nearly white - pixels
in the image and replaces them with red ones before saving the
final output as a JPEG. The final output is shown below.
redboat.jpg
|