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

Active Image Active Image Samples

Please view complete list of samples

Sample 1. Drawing pie charts and text lines of different fonts.
Diagram.vbs


Dim im
dim dat1,r1,g1,b1
Set im = CreateObject("ActiveImage.Images.1")

im.CreateImage 300,300

im.SetColor 0,255,0
im.Fill 299,299

dat = "20,45,15,9,11"
r = "255,255 ,255,0 ,0 "
g = "0 ,0,255,255 ,0"
b = "0 ,255,127,255,255"

dat1 = split(dat,",")
r1 = split(r,",")
g1 = split(g,",")
b1 = split(b,",")
x = 0

For i = 0 to 4
im.SetColor r1(i),g1(i),b1(i)
im.DrawFilledArc 150,150,160,160,(x*3.6),(dat1(i)+x)*3.6
x = x + dat1(i)
next

im.SetFont 4
im.SetColor 0,0,0
im.DrawText 20,20 , "HTTP://WWW.TONEC.COM/"
im.SetFont 0
im.SetColor 0,0,0
im.DrawText 20,40 , "HTTP://WWW.TONEC.COM/"

im.WriteToFile "C:\AI\diagram.png"

im.SetImageType 1
im.SetJpegQuality 100
im.WriteToFile "C:\AI\diagram.jpg"
im.DestroyImage
Set im = Nothing


diagram.jpg diagram.png
Picture 2. diagram.jpg (size - 29 Kb) Picture 3. diagram.png (size - 3 Kb)


Sample 2. Read from file and save to a database
Database.vbs


Dim im, rs

Set im = CreateObject("ActiveImage.Images.1")

im.ReadFromFile "C:\AI\diagram.png"

Set rs = CreateObject("adodb.recordset")
dsn = "tonec"
rs.Open "pictures", dsn, 2, 3
rs.AddNew
im.WriteToDatabase rs.Fields("Bitmap")
rs.Update
rs.Close
im.DestroyImage
Set im = nothing



Sample 3 . Single image manipulation: read image from file, find canvas dimensions, copy the part of image with linear transformations and save to Jpeg file with lowest quality.
Rose.vbs


Dim im, rs
Set im = CreateObject("ActiveImage.Images.1")
im.SetImageType 1
im.ReadFromFile "C:\AI\rose.jpg"
h = im.GetHeight
w = im.GetWidth


im.SetImage 1
im.CreateImage w/2,h/2
im.CopyImageResize 1,0,0,0,0,0,w/2,h/2,w,h
im.SetJpegQuality 25
im.WriteToFile "C:\AI\copyrose.jpg"
im.DestroyImage
im.SetImage 0
im.DestroyImage

Set im = Nothing


rose.jpg copyrose.jpg
Picture 4. rose.jpg (size - 6 Kb) Picture 5. copyrose.jpg (size - 1.6 Kb)


Implemented Methods:


Method Description
CopyImage Copy image part
CopyImageResize Copy image part with resize
CreateImage Create image
DestroyImage Destroy image and clean up the memory
DrawArc Draw Arc
DrawEllipse Draw Ellipse
DrawFilledArc Draw filled arc (can be used to create pie charts)
DrawFilledEllipse Draw filled ellipse (can be used to create charts)
DrawFilledPolygon Draw filled polygon
DrawFilledRectangle Draw filled rectangle
DrawLine Draw line
DrawPolygon Draw polygon
DrawRectangle Draw rectangle
DrawText Draw text
DrawTextAngle Draw text with angle
Fill Color fill (changing color for another color)
GetColorBlue Get blue value of current color
GetColorGreen Get green value of current color
GetColorRed Get red value of current color
GetFont Get font for text output operations
GetHeight Get image height
GetImage Get image handle
GetImageType Get image format (PNG, Jpeg)
GetInterlace returns true if image is interlaced
GetJpegQuality Get Jpeg quality value
GetLineThickness Get current line thickness (used in DrawLine, etc)
GetPixelBlue Get blue value for a pixel
GetPixelGreen Get green value for a pixel
GetPixelRed Get red value for a pixel
GetTransparent Returns current transparent color
GetWidth Get image width
ReadFromDatabase Read image from database
ReadFromFile Read image from file
ReadFromVariable Read image from variable
SetColor Set foreground color
SetFont Select current font
SetImage Select active image
SetImageType Set image format (PNG, Jpeg)
SetJpegQuality Set Jpeg quality value
SetLineThickness Set line thickness for simple draw operations
SetPixel Set pixel
SetTransparent Set transparent color
WriteToDatabase Write image to database
WriteToFile Write image to file
WriteToVariable Write image to variable (can be also used to write image directly to browser data stream)

New Since v4.2
ConvertToPalette Converts TrueColor image to palletized one
CreateImagePalette Creates Palette (256 color table)
ConvertToMonochromeAuto Converts image to black and white one
DrawTextTTF Draws text with selected TrueType font
DrawTextAngleTTF Draws text with selected angle and TrueType font
GetColorAlpha Gets the alpha channel value of active foreground color
GetColorTotal Returns total number of colors used. Works only for palletized images
GetPixelAlpha Gets the value of alpha channel component of the color
GetTrueColor Returns true if image is in TrueColor
SetAlphaColor Sets color with alpha channel component. For palletized image any non-zero value will result in setting this color as transparent.
SetAlphaBlending Enables/Disables alpha blending
SetColorByIndex Sets color from already created color table (palette)
SetFontPathTTF Sets path to TrueType font directory
SetFontPathTTFAuto Sets path to TrueType font automatically
SetFontSizeTTF Sets true type font size
SetSaveAlpha Enables/Disables saving alpha channel color information

New Since v4.5
ConvertToGrayScale Converts image to Grayscale
CopyImageMerge Copy image part and merge
WriteToVariableVariant   Write image to variable (can be also used to write image to OleLoadPicture in VC++)

New Since v4.7
CopyImageRotate Rotate source image and copy to a new image.
CopyImageSimpleRotate Rotate source image and copy to a new image.
DestroyAll Destroy images and free allocated memory

New Since v4.9
GetTextTTFRectangle Get text string dimensions.
ConvertToPaletteNoAlpha Converts TrueColor image to palletized one without alpha channel.
SetTextAntialias Sets text antialiasing for palette images




For more information you may take a look at the manual.

and more samlpes page.

Source code compilation instructions (not needed for most users)

If you want to build the component from the source code:

Note that Tonec Inc. also provides custom programming and cost-effective offshore software development services. Check out our Free Products page.

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.