description | download | manual | ||
If you want to build T1CFreeImage ActiveX component yourself, you will need to compile libraries (gd, libpng, zlib) first and then compile T1CfreeImage source files. To compile the libraries you need to create three subdirectories (gd, libpng, zlib) in your project home directory tree.
You can compile the libraries following the instructions included along with source code in their original distribution files. You can also take the project frame from T1CfreeImage distribution file, simply unzip and move libraries source code to created directories, and build the T1CFreeImage project. Since the projects have dependencies, all libraries should be compiled automatically and in the result you will get the ATL component in a single .dll file.
To build the component in MS VC 6.0 ++, you need to :
Method Name: CreateImage Parameters: [in] int w, [in] int h Add the code: int white;
img = gdImageCreate(w, h); white = gdImageColorAllocate(img, 255, 255, 255); |
Method Name: SetColor Parameters: [in] int R, [in] int G, [in] int B Add the code: color = gdImageColorAllocate(img, R, G, B);
if (color == (-1)) { color = gdImageColorAllocate(img, R, G, B); color = gdImageColorClosest(img, R, G, B); } |
Method Name: DrawLine Parameters: [in] int x1, [in] int y1, [in] int x2, [in] int y2 Add the code: gdImageLine(img x1, y1, x2, y2, color);
|
Method Name: DrawText Parameters: [in] int x, [in] int y, [in] BSTR str Add the code: CHAR *lpString;
int iMessageSize; iMessageSize=wcslen(str)+1; lpString = new CHAR[iMessageSize]; // Change the Message From Unicode to MBCS if (WideCharToMultiByte(CP_ACP,0,str,-1,lpString,iMessageSize,NULL,NULL)==FALSE) { return(S_FALSE); } gdImageString(img, gdFontSmall, x, y, (unsigned char *)lpString, color); delete lpString; |
Method Name: SaveToFile Parameters: [in] BSTR strFile Add the code: FILE *out;
CHAR *lpString; int iMessageSize; iMessageSize=wcslen(strFile)+1; lpString = new CHAR[iMessageSize]; // Change the Message From Unicode to MBCS if (WideCharToMultiByte(CP_ACP,0,strFile,-1,lpString,iMessageSize,NULL,NULL)==FALSE) { return(S_FALSE); } out = fopen(lpString, "wb"); /* Write PNG */ gdImagePng(img,out); fclose(out); delete lpString; |
Here is the sample (t1c.vbs) that shows the usage of free ActiveX component on your ASP page. You can also use the component from VBS file, VBA for Access, Words and any other applications that support ActiveX (ATL) components.
Dim im Set im = CreateObject("T1CFreeImage.Images.1") im.CreateImage 100,100 im.SetColor 255,0,0 im.DrawLine 10,10,30,30 im.SetColor 0,0,255 im.DrawText 10,40,"T1CFreeImage" im.SaveToFile "C:\test.png" Set im = Nothing | |
Figure 1. Test.png |
Privacy Policy | |
��1999-2005. Tonec, Inc. All rights reserved. |