description | features | samples | manual | download | buy | |||
CopyImage , CopyImageResize, CopyImageRotate *, CopyImageSimpleRotate*, CopyImageMerge *, CreateImage, ConvertToGrayScale *, ConvertToMonochromeAuto *, ConvertToPalette *, ConvertToPaletteNoAlpha *, CreateImagePalette *, DestroyImage, DrawArc, DrawEllipse, DrawFilledArc, DrawFilledEllipse, DrawFilledPolygon, DrawFilledRectangle, DrawLine, DrawPolygon, DrawRectangle, DrawText, DrawTextAngle, Fill, DrawTextTTF *, DrawTextAngleTTF *, Fill, GetColorBlue, GetColorGreen, GetColorRed, GetColorAlpha *, GetColorTotal *, GetPixelAlpha *, GetTextTTFRectangle *, GetTrueColor *, GetFont, GetHeight, GetImage, GetImageType, GetInterlace, GetJpegQuality, GetLineThickness, GetPixelBlue, GetPixelGreen, GetPixelRed, GetTransparent, GetWidth, ReadFromDatabase, ReadFromFile, ReadFromVariable, SetColor, SetFont, SetFontTTF, SetImage, SetImageType, SetJpegQuality, SetLineThickness, SetAlphaColor *, SetAlphaBlending *, SetColorByIndex *, SetFontPathTTF *, SetFontPathTTFAuto *, SetFontSizeTTF *, SetSaveAlpha *, SetPixel, SetTextAntialias, SetTransparent, WriteToDatabase, WriteToFile, WriteToVariable, WriteToVariableVariant *
* - new methods in v4.2, v4.5 , v4.7 and v4.9
Component is distributed with complete source code that can be easily extended with your own functionality. Another advantage is that you can host the component on the servers where system security policy allows running only open source components.
Let us take a close look at the component internals on a simple sample.
Used method: CreateImage (width, height)
CreateImage allocates memory and creates black image with specified image dimensions (width and height) in a special internal format. You need to select image type every time you need to import/export image to/from the component e.g. saving image to file, database or data stream.
Used method: SetImageType (style)
Image format can be set with SetImageType method. Type 0 sets PNG format (default), type 1- Jpeg. You need also to define the type when reading image from database or variable.
Used method: SetFont (num), and TrueType font - SetFontPathTTFAuto, SetFontTTF, DrawTextTTF
Component has a number of predefined font styles: 0 - Small (default) , 1 - MediumBold , 2- Large, 3 - Tiny, 4 - Giant
Dim im |
‘ Define object variable | |
‘ Create object | ||
im.CreateImage 150,75 | ‘ Create image with specified width and height | |
im.SetSaveAlpha 0 | ||
im.SetColor 191,255,255 | ‘Set foreground color in RGB format (white) | |
im.Fill 0,0 | ‘ Fill from the current point with foreground color | |
im.SetColor 0,0,0 | ‘ Set foreground color in RGB format (black) | |
im.SetFont 0 | ‘ Set font number to 0 (Small) | |
im.DrawText 10,10, "Small - (default) " &im.GetFont | ‘ Draw text and the number of active font | |
im.SetFont 1 | ||
im.DrawText 10,20, "Medium Bold - " & im.GetFont | ||
im.SetFont 2 | ||
im.DrawText 10,30, "Large - " & im.GetFont | ||
im.SetFont 3 | ||
im.DrawText 10,44, "Tiny - " & im.GetFont | ||
im.SetFont 4 | ||
im.DrawText 10,50, "Giant - " & im.GetFont | ||
'TrueType font | ||
im.SetPathFontTTFAuto | ||
im.SetFontSize 14 | ||
im.SetFontTTF "verdanab" | ||
im.DrawTextTTF 10,60, "TrueType" | ||
‘ Save Image to file. Default type 0 corresponds to PNG format. | ||
im.SetImageType 1 | ' Set Jpeg format | |
im.SetJpegQuality 100 | ‘ Set Jpeg quality | |
im.WriteToFile "C:\font.jpg" | ||
im.DestroyImage | ‘ Delete image and free memory | |
‘ Clear the variable | ||
Picture 1. |
Used method: SetLineThickness (num). Line thickness (in number of pixels) is applied for DrawLine, DrawArc and DrawPolygon methods. Default value is 1
Used method: DrawPolygon (array a, integer point_num)
This sample draws polygons. You need to define coordinates array and consequently fill it with x,y pairs. For example coord(0) = x1, coord(1) = y1, etc. In a call to DrawPolygon you have to specify the array and the number of points (or x, y pairs) to draw.
ConvertToGrayScale () | Converts image to GrayScale. | ||||||||||||||||||||||||||||||||||||||||||||||||
ConvertToMonochromeAuto () | Converts TrueColor image to black and white. This method can be used to create WBMP images. See "Graphics for WAP" sample. | ||||||||||||||||||||||||||||||||||||||||||||||||
ConvertToPalette () | Converts TrueColor image to palletized one. This method can be used to create transparent PNG images. Seecreating transparent images sample. | ||||||||||||||||||||||||||||||||||||||||||||||||
ConvertToPaletteNoAlpha () | Converts TrueColor image to palletized one without alpha channel (most accurate color conversion despite decreasing color depth from 4294967296 to 256 colors). | ||||||||||||||||||||||||||||||||||||||||||||||||
CopyImage | (destnum, srcnum, destX, destY, srcX, srcY, width, height) - Copy image part srcnum – Image handle (number) to copy from [0 - 10] destnum – Image handle (number) to copy to [0 - 10] (destX, destY)– coordinate to place a part of source image from (srcX, srcY) with specified width and height width – integer. Image width height – integer. Image height | ||||||||||||||||||||||||||||||||||||||||||||||||
CopyImageMerge | (destnum, srcnum, destX, destY, srcX, srcY, width, height, opaque) - Copy image part with merge srcnum – Image handle (number) to copy from [0 - 10] destnum – Image handle (number) to copy to [0 - 10] (destX, destY)– destination coordinates to place a part of source image from (srcX, srcY) with specified width and height width – integer. Image width height – integer. Image height opaque – integer [0..100]. Opaque level | ||||||||||||||||||||||||||||||||||||||||||||||||
CopyImageResize | (destnum, srcnum, destX, destY, scrX, srcY, destWidth, destHeight, srcWitdh, srcHeight) - Copy image part with resize srcnum – Image handle (number) to copy from [0 - 10] destnum – Image handle (number) to copy to [0 - 10] (destX, destY)– coordinate of destination image to place a part of source image beginning in (srcX, srcY) with specified srcWidth and srcHeight destWidth, destHeight– width and height of destination image. Image is resized if srcWidth != destWidth or srcHeight != destHeight | ||||||||||||||||||||||||||||||||||||||||||||||||
CopyImageRotate | (destnum,srcnum,angle) Rotate source image and copy to a new image. The new image will be created automatically. The color of background can be set with SetColor method. New image dimensions will be changed to accommodate rotated image. srcnum - Image handle (number) to copy from [0 - 10] destnum - Image handle (number) to copy to [0 - 10] angle - angle to rotate image | ||||||||||||||||||||||||||||||||||||||||||||||||
CopyImageSimpleRotate | (destnum,srcnum,dstX,dstY,scrX,srcY,Witdh,Height) - Rotate source image and copy to a new image. The new image should exist. This method uses different algorithm to rotate images. srcnum - Image handle (number) to copy from [0 - 10] destnum - Image handle (number) to copy to [0 - 10] (destX, destY) - coordinates of center of the rotated copy (srcX, srcY) - coordinates of upper left corner of the source image. angle - angle to rotate image | ||||||||||||||||||||||||||||||||||||||||||||||||
CreateImage | (width, height) - Allocate memory and create image in internal format width – integer. Image width height – integer. Image height | ||||||||||||||||||||||||||||||||||||||||||||||||
CreateImagePalette | (width, height) – Creates palette (256 color table) width – integer. Image width height – integer. Image height | ||||||||||||||||||||||||||||||||||||||||||||||||
DestroyImage | - Destroy active image that was specified in a call to SetImage and clean up the memory. By default the image with 0 handle is destroyed. Returns True is a image destroyed succsesfully | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawArc | (cx, cy, w, h, s, e) - Draw Arc cx,cy – arc center coordinate w,h – arc width and height s,e – start and end angles [0 – 360] | ||||||||||||||||||||||||||||||||||||||||||||||||
Sample
| |||||||||||||||||||||||||||||||||||||||||||||||||
DrawEllipse | (cx,cy, w, h, s, e) - Draw Ellipse cx,cy – ellipse center coordinate w,h –ellipse width and height s,e – start and end angles [0 – 360] | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawFilledArc | (cx, cy, w, h, s, e) - Draw filled arc (can be used to create pie charts) cx,cy – arc center coordinate w,h – arc width and height s,e – start and end angle [0 – 360] | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawFilledEllipse | (cx, cy, w, h, s, e) - Draw filled ellipse (can be used to create charts) cx,cy – ellipse center w,h – ellipse height and width s,e – start and end angles [0 – 360] | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawFilledPolygon | (coords, num) - Draw filled polygon coords – one dimension array that specifies all coordinate pairs. First value (X1) should be placed in the array element with zero index num – Number of points (x,y pairs). This value shouldn't be greater than 1998. | ||||||||||||||||||||||||||||||||||||||||||||||||
Sample
| |||||||||||||||||||||||||||||||||||||||||||||||||
DrawFilledRectangle | (x1,y1,x2,y2)- Draw filled rectangle x1,y1,x2,y2 – coordinates of upper left and lower right rectangle corners. DrawFilledRectangle draws with active foreground color and you should use SetColor method if you want to change it. | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawLine | (x1,y1,x2,y2) - Draw line x1,y1,x2,y2 - coordinates of the end and start line points. Line thickness can be set using SetLineThickness method. DrawLine draws with active foreground color and you may change it calling SetColor method. | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawPolygon | (coords, num) - Draw polygon coords – one dimension array that specifies all coordinate pairs. First value (X1) should be placed in the array element with zero index num – Number of points (x,y pairs). The value shouldn't be greater than 1998 [0..1998]. | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawRectangle | (x1,y1,x2,y2) - Draw rectangle x1,y1,x2,y2 – coordinates of upper left and lower right rectangle corners. DrawRectangle draws with active foreground color and you should use SetColor method if you want to change it. Line thickness can be set in a call to SetLineThickness method. | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawText | (x,y,text) - Draw text x,y – define start point for text output. text – text string to draw | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawTextAngle | (x, y, angle, text) - Draw text with angle x,y – define start point for text output.. angle – text slope [0..360] text – text string to draw | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawTextAngleTTF | (x,y,angle,text)– Draw text with selected angle and TrueType font. x,y – define start point for text output.. angle – text slope [0..360] text – text string to draw | ||||||||||||||||||||||||||||||||||||||||||||||||
DrawTextTTF | (x,y,text)– Draw text with selected TrueType font x,y – define start point for text output.. text – text string to draw | ||||||||||||||||||||||||||||||||||||||||||||||||
Fill | (x,y) - Color fill (changing color on another) Fill method replaces all points of the same color adjacent to start point (x,y) on active foreground color. x,y – fill start point You can change the color with SetColor. This method may be useful to change black background after image creation. | ||||||||||||||||||||||||||||||||||||||||||||||||
GetColorAlpha | Get alpha channel value of active foreground color | ||||||||||||||||||||||||||||||||||||||||||||||||
GetColorBlue | Get blue value of active foreground color | ||||||||||||||||||||||||||||||||||||||||||||||||
GetColorGreen | Get green value of active foreground color | ||||||||||||||||||||||||||||||||||||||||||||||||
GetColorTotal | Return total number of colors used. Works only for palletized images. | ||||||||||||||||||||||||||||||||||||||||||||||||
GetColorRed | Get red value of active foreground color | ||||||||||||||||||||||||||||||||||||||||||||||||
GetFont | Get font style for text output operations Returns active font style for text output operations 0 - Small 1- MediumBold 2 - Large 3 - Tiny 4 - Giant | ||||||||||||||||||||||||||||||||||||||||||||||||
Sample
| |||||||||||||||||||||||||||||||||||||||||||||||||
GetHeight | Get image height Returns image height For example you may determine image height after image read operation and resize the image if necessary. | ||||||||||||||||||||||||||||||||||||||||||||||||
GetImage | Get image handle Returns the number of active image. [0..10]. You can set active image in a call to SetImage. | ||||||||||||||||||||||||||||||||||||||||||||||||
GetImageType | Get image format (PNG, Jpeg) Returns active image format (0 – PNG , 1 – Jpeg). You can set image format with SetImageType. Image format is used only for import/export operations. | ||||||||||||||||||||||||||||||||||||||||||||||||
GetInterlace | returns true if image is interlaced | ||||||||||||||||||||||||||||||||||||||||||||||||
GetJpegQuality | Get Jpeg quality value Return default value or the value set with SetJpegQuality. You can set necessary Jpeg quality if you save the image in Jpeg format to variable, database or file in a call to SetJpegQuality. | ||||||||||||||||||||||||||||||||||||||||||||||||
GetLineThickness | Get current line thickness (used in DrawLine, etc) | ||||||||||||||||||||||||||||||||||||||||||||||||
GetPixelAlpha | (x,y) Gets the value of alpha channel component of the color | ||||||||||||||||||||||||||||||||||||||||||||||||
GetPixelBlue | (x,y) Get blue value for a pixel Returns blue component of a pixel at (x,y) coordinate. B (RGB) [0..255] | ||||||||||||||||||||||||||||||||||||||||||||||||
GetPixelGreen | (x,y) Get green value for a pixel Returns green component of a pixel at (x,y) coordinate. G (RGB) [0..255] | ||||||||||||||||||||||||||||||||||||||||||||||||
GetPixelRed | (x,y) Get red value for a pixel Returns red component of a pixel at (x,y) coordinate. R (RGB) [0..255] | ||||||||||||||||||||||||||||||||||||||||||||||||
GetTextTTFRectangle | Get text string dimensions Returns variant array [1,4] | ||||||||||||||||||||||||||||||||||||||||||||||||
GetTransparent | Returns true if image is transparent | ||||||||||||||||||||||||||||||||||||||||||||||||
GetTrueColor | (filename) Returns true if image is in TrueColor | ||||||||||||||||||||||||||||||||||||||||||||||||
GetWidth | Get image width Returns image width For example you may determine image height after image read operation and resize the image if necessary. | ||||||||||||||||||||||||||||||||||||||||||||||||
ReadFromDatabase | (AdoRecordset)- Read image from database Use ADO for database access. Methods DAO (for MS Access) are not supported yet. You need to have open recordset with cursor 2 (adOpenDynamic) and blocking type 3 (adLockOptimistic). | ||||||||||||||||||||||||||||||||||||||||||||||||
ReadFromFile | (namefile) Read image from file namefile – file name (can include file path) For example, ReadFromFile “C:\test.png” By default, ReadFromFile reads image in PNG format. If you want to read Jpeg image, you need to call SetImageType 1 before calling ReadFromFile. ( 0 – PNG, 1 – Jpeg) | ||||||||||||||||||||||||||||||||||||||||||||||||
ReadFromVariable | (var) Read image from variable var – variable of Variant type. You can save image in variable using WriteToVariable. By default ReadFromVariable reads image in PNG format. If you want to read Jpeg image, you need to call SetImageType 1 before calling ReadFromVariable. ( 0 – PNG, 1 – Jpeg) | ||||||||||||||||||||||||||||||||||||||||||||||||
SampleShows how to read image from calling program variable. You can upload the image from the client side in the same way, process it memory and save back without the creation of any temporary files.
| |||||||||||||||||||||||||||||||||||||||||||||||||
SetAlphaBlending | (newval)–Enables/Disables alpha blending. Value 1 turns alpha lending mode on when each next element of the image will be drawn ith a value of transparency. See Alpha Blending Sample. | ||||||||||||||||||||||||||||||||||||||||||||||||
SetAlphaColor | (r,g,b,a) New method to set color with alpha channel. For palletized image any non-zero value will result in setting this color as transparent. For example if you draw a filled rectangle with alpha value set to 1 on a palletized image, you will get transparent box. See image transparency sample. integer r [0..255] - set red component integer g [0..255] - set green component integer b [0..255] - set blue component integer a [0..127] - set alpha channel component. 0 - image is opaque. 127 - image is fully transparent. 64 - image is half tranparent. | ||||||||||||||||||||||||||||||||||||||||||||||||
SetColor | (R,G,B) Set foreground color R - red image component [0..255] G - green image component [0..255] B - blue image component [0..255] Different drawing operations (like DrawText, DrawRectangle, DrawLine, Fill etc) will be made with this active foreground color. Sample colors:255,255,255 – white color0,0,0 – black color 255,0,0 – red color 0,0,255 – blue color 127,127,127 – grey color | ||||||||||||||||||||||||||||||||||||||||||||||||
SetColorByIndex | (n) Set color from already created color table (palette). n - color number/index in the color table. | ||||||||||||||||||||||||||||||||||||||||||||||||
SetFont | (num) - Select current font Set active font style 0 - Small (default) 1- MediumBold 2 - Large 3- Tiny 4 - Giant For more information you may check out the GetFont sample. | ||||||||||||||||||||||||||||||||||||||||||||||||
SetFontPathTTF | (str)–Set path to the TrueType font directory. | ||||||||||||||||||||||||||||||||||||||||||||||||
SetFontPathTTFAuto | Set path to TrueType font automatically. For example if Windows NT/2000 has been installed to C:\winnt, then the path is C:\Winnt\Fonts | ||||||||||||||||||||||||||||||||||||||||||||||||
SetFontSizeTTF | (size) Set true type font size | ||||||||||||||||||||||||||||||||||||||||||||||||
SetFontTTF | (str) –Set true type font name. For example, "verdana". | ||||||||||||||||||||||||||||||||||||||||||||||||
SetImage | (num) - Select active image Set active image. All image operations will be in progress with the selected image [0..10] | ||||||||||||||||||||||||||||||||||||||||||||||||
SetImageType | (num) Set image format (PNG, Jpeg) Set image format for export/import operations (reading/writing file, database, variable) num : 0 - PNG (default), 1 - Jpeg If you try to read Jpeg using PNG format converter, error exception "No Image!" will be thrown. If you want to handle errors in VBScript you need to run “On Error Resume Next” command before calling SetImageType method | ||||||||||||||||||||||||||||||||||||||||||||||||
SetJpegQuality | (quality) Set Jpeg quality value integer quality [0..100] You can set necessary Jpeg quality if you save the image in Jpeg format to variable, database or file. | ||||||||||||||||||||||||||||||||||||||||||||||||
SetLineThickness | (width) Set line thickness for simple draw operations Positive integer width (positive), default = 1 Sets line thickness in pixels for common draw methods (DrawLine, DrawPolygon, DrawArc, etc). | ||||||||||||||||||||||||||||||||||||||||||||||||
SetPixel | (x,y) -Set pixel Draw a pixel in (x,y) coordinate with active foreground color. | ||||||||||||||||||||||||||||||||||||||||||||||||
SetSaveAlpha | (newval) Enable/Disable saving alpha channel color information. See SaveAlpha Sample Value 1 sets the mode when alpha channel information will be saved in image | ||||||||||||||||||||||||||||||||||||||||||||||||
SetTextAntialias | (num) Sets text antialiasing for palette images Num: 1 – turn on text antialiasing 0 – turn off text antialiasing | ||||||||||||||||||||||||||||||||||||||||||||||||
SetTransparent | (num) Set current color as transparent Num: 1 – turn on image transparency 0 – turn off image transparency | ||||||||||||||||||||||||||||||||||||||||||||||||
WriteToDatabase | (AdoRecordset) Write image to database Use ADO for database access. Methods DAO (for MS Access) are not supported yet. You need to have open recordset with cursor 2 (adOpenDynamic) and blocking type 3 (adLockOptimistic). | ||||||||||||||||||||||||||||||||||||||||||||||||
WriteToFile | (namefile) –Write image to file You need to specify image type (call SetImageType) if you want to change image format | ||||||||||||||||||||||||||||||||||||||||||||||||
WriteToVariable | (var)–Write image to variable (can be also used to write image directly to browser data stream) var –variable has VARIANT type. You may also need to specify image format in a call to SetImageType (num) | ||||||||||||||||||||||||||||||||||||||||||||||||
WriteToVariableVariant | (var) –Write image to variable (can be also used to write image to OleLoadPicture in VC++) var –variable has VARIANT type. You may also need to specify image format in a call to SetImageType (num) |
If you want to catch errors returned from the component, you have to enable it in ASP/VBScript code, adding “On Error Resume Next”. The component throws the following exceptions:
Privacy Policy | |
© 1999-2007. Tonec, Inc. All rights reserved. |