This site contains information and files for gdCOM.dll, a COM compliant dll providing the services of the gd 2.0.1 graphics library. The latest build of gdCOM is 2.0.1.6.Contents
Thomas Boutell's gd graphics library! An answer enough for anyone.How gdCOM?The gd graphics library has served as the foundation for many applications needing dynamic image creation and manipulation, especially those tied to the web. gd's standard image format prior to version 1.6 was the GIF format. Subsequently a large legal darkness descended upon the net wide use of the GIF graphics file format, as a result of the Unisys LZW compression algorithm patent. With this change, gd embraced the PNG standard (which is arguably a big step forward from GIF) as its efficient standard image format. As of gd 1.8, true colour JPEG image handlig is also suported.
All this upheaval prompted me to re-investigate the possibility of using gd in a windows environment. Primarily to solve some of the struggles I was having doing what would otherwise have been unix simple things in an IIS ASP context (sometimes I'm forced to do things the Hard way..).
Out of this, gdCOM was beaten into shape.
Essentially, gdCOM is an activeX OLE automation dll. This means that once installed, gdCOM objects can be created and used from any COM compliant container (like ASP pages or Visual Basic or anything which uses VBScript for that matter).gdCOM is built from the latest source distributions of gd, zlib , libpng and jpeg-6b. The functions generally made available by gd in a compiled library are then wrapped in COM interface routines with conversion between the required oleautomation data types. A very minimal set of helper routines were also added, to aid in the use of file related functions from COM containers that have trouble providing file handles for gd data output.
Visual Basic Code Example:
Where gdCOM?Assuming the gdCOM component has been installed, open a new project and set the project references to include the "gdCOM 2.0.1.x Type Library". Once that is done, the Visual Basic equivalent of gd's simple C demo is as follows;ASP ExamplePrivate Sub Form_Load()
' Create a New Instance of the gdCOM objectEnd Sub
Dim gdInstance As New gdCOM' Define a pointer for the image Data
Dim ImagePointer As Long' Define Variables to hold Color indexes
Dim Black As Long
Dim White As Long' Create a New Image of a specified size
ImagePointer = gdInstance.ImageCreate(64, 64)
' Use the returned Image Pointer to define two colors
Black = gdInstance.ImageColorAllocate(ImagePointer, 0, 0, 0)
White = gdInstance.ImageColorAllocate(ImagePointer, 255, 255, 255)' Draw a line
Call gdInstance.ImageLine(ImagePointer, 0, 0, 63, 63, White)' Write a file using one of the "helper" routines
Call gdInstance.ImagePngHelper(ImagePointer, "test.png")
' VERY VERY Important step. Destroy the Image data held by the object
Call gdInstance.ImageDestroy(ImagePointer)
' De-allocate the gdCOM object
Set gdInstance = Nothing
Again, assuming the gdCOM dll has been installed. The following ASP VBScript code replicates gd's simple C demo.<%
dim OutputFilename, ImagePointer, Black, Whiteset gdInstance = server.createobject("gdCOM.gdCOM.1")
ImagePointer = gdInstance.ImageCreate(64,64)
Black = gdInstance.ImageColorAllocate(ImagePointer,0,0,0)
White = gdInstance.ImageColorAllocate(ImagePointer,255,255,255)call gdInstance.ImageLine(ImagePointer,0,0,63,63,White)
OutputFilename = request.servervariables("APPL_PHYSICAL_PATH") + "test.png"
call gdInstance.ImagePngHelper(ImagePointer, OutputFileName)
call gdInstance.ImageDestroy(ImagePointer)
set gdInstance = nothing
%>
NOTE: If you wish to use the generated file immediately in the same ASP page that generated the image, you will need to use the direct binary data return method on your image data - as shown in the following example:
<%
Option Explicit
' Define an Instance Variable, Image Pointer and Color Variables
Dim gdInstance, ImagePointer, Black, White
' Create a New Instance of the gdCOM Object
Set gdInstance = Server.CreateObject("gdCOM.gdCOM.1")
' Create a New Image of the Specified Size
ImagePointer = gdInstance.ImageCreate(64,64)
' Use the Returned Image Pointer to Allocate Two Colors
Black = gdInstance.ImageColorAllocate(ImagePointer,0,0,0)
White = gdInstance.ImageColorAllocate(ImagePointer,255,255,255)
' Draw a Line
Call gdInstance.ImageLine(ImagePointer,0,0,63,63,White)
' Use the ASP Response Object to set the Content Type to PNG
Response.ContentType = "image/PNG"
' Wrtie out the Binary PNG image directly to the HTML stream
Response.BinaryWrite gdInstance.ImagePngBinaryData(ImagePointer)
' VERY VERY Important Step - Destroy the Image Data Held By the Object
Call gdInstance.ImageDestroy(ImagePointer)
' Release the gdCOM Instance
Set gdInstance = Nothing
%>
The latest version of gdCOM binary should be available at the Source Forge site http:/gdcom.sourceforge.net/License Terms
A complete list of the wrapped functions is provided here.
As gdCOM wraps the functionality provided by gd, the gd documentation might be worth a look see.
NOTE: Currently the gdCOM source release is available in varying degrees of quality through cvs...
Bugs? See anything strange happen? Suggestions? Help? Then try gdCOM SourceForge Pages.
As gdCOM is a derived work from Thomas Boutell's gd.Miscellaneous
This gdCOM page and hosting has been provided by.