Sample 13 - Copy/resize of transparent image part, saving it to GIF and palette PNG files Creating a transparent image, drawing, writing to file, reading from file. Copy and resize.
> ResizeTransparentPalette.vbs
>     Dim im
>     Set im = CreateObject("ActiveImage.Images.1")
>     im.SetImageType 1

>     'Set image dimensions
>     w1 = 300
>     h1 = 200

>     'Create Palette image
>     im.CreateImagePalette w1,h1
>     'Set white color as transparent
>     'First specified color becomes background
>     im.SetColor 255,255,255
>     'Set current color to transparent
>     im.SetTransparent 1

>     'Draw red circle
>     im.SetColor 255,0,0
>     im.DrawEllipse CInt(w1/2), CInt(h1/2), 100,100

>     'Set GIF image type
>     im.SetImageType 3
>     im.WriteToFile "C:\AI\circle.gif"
>     im.DestroyImage

>     'Set GIF image type
>     im.SetImageType 3
>     'Load file
>     im.ReadFromFile "C:\circle.gif"

>     w1 = im.GetWidth
>     h1 = im.GetHeight

>     im.SetImage 1
>     w2 = 100
>     h2 = 100
>     'Create palette image
>     im.CreateImagePalette w2,h2
>     im.SetColor 255,255,255
>     im.SetTransparent 1
>     im.SetColor 0,0,255

>     im.DrawFilledRectangle 0,CInt(h2/2)-5,w2,CInt(h2/2)+5
>     im.DrawFilledRectangle CInt(w2/2)-5,0,CInt(w2/2)+5,h2

>     'Set GIF image type
>     im.SetImageType 3
>     im.WriteToFile "C:\AI\plus.gif"
>     im.DestroyImage

>     'Set GIF image type
>     im.SetImageType 3
>     'Load from file
>     im.ReadFromFile "C:\AI\plus.gif"

>     w2 = im.GetWidth
>     h2 = im.GetHeight
>     x1 = w1/2 - w2/2
>     y1 = h1/2 - h2/2

>     'Copy and resize image
>     im.CopyImageResize 0,1,CInt(x1),CInt(y1),0,0,CInt(w2/2),Cint(h2/2),CInt(w2), CInt(h2)

>     im.SetImage 0
>     im.WriteToFile "C:\AI\rti.gif"
>     im.DestroyImage
>     im.SetImage 1
>     im.DestroyImage

>     Set im = Nothing
> Picture 1. circle.gif (transparent, size - 2,1 Kb) | Picture 2. plus.gif (transparent, size - 1 Kb)
> Picture 3. rti.gif (transparent, size - 2,3 Kb) |
If you have any questions or bug reports, write to active.image@tonec.com for technical support.
| © 2000-2001 All Rights Reserved Tonec Inc., 16835 Algonquin Street #400, Huntington Beach, CA, 92649, fax: (509) 752-1450, e-mail: info@tonec.com