Tonec.com Bringing Internet Technology Innovations to Market since 1991
  News Products Outsourcing About Us Contact Us
what's new?what's new? featuresfeatures samplessamples manualmanual downloaddownload buybuy
  Tonec Homepage
ProductsActive Imagesamples

Please view complete list of samples

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:\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:\plus.gif"
im.DestroyImage

'Set GIF image type
im.SetImageType 3
'Load from file
im.ReadFromFile "c:\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:\rti.gif"
im.DestroyImage
im.SetImage 1
im.DestroyImage

Set im = Nothing


 circle plus
 Picture 1. circle.gif (transparent, size - 2,1 Kb) Picture 2. plus.gif (transparent, size - 1 Kb)
 rti.gif
 Picture 3. rti.gif (transparent, size - 2,3 Kb)

Next sample >> 

If you have any questions or bug reports, write to support@tonec.com for technical support.

  TonecPrivacy Policy
  © 1999-2005. Tonec, Inc. All rights reserved.