<[ 

//*********************************************************************************************************************************
// Example of GD with GDLibrary.dll wrapper.

// Edited quote from boutell.com:
// GD is an open source code library for the dynamic creation of images. GD creates PNG, JPEG and GIF images, among other formats. 
// GD is commonly used to generate charts, graphics, thumbnails, and most anything else, on the fly. While not restricted to use 
// on the web, the most common applications of GD involve web site development. 

// Requirements
// bgd.dll - GD library binary, have to be located in the same folder with engine.exe.
// GDLibrary.dll - ActiveX wrapper DLL, needs to be registered with regsvr32 before use

// GDLibrary wrapper was developed by Trevor Herselman. GD is copyright 2005 Boutell.com, Inc. GD was developed by Thomas Boutell.

//*********************************************************************************************************************************

class gdPoint
    local x
    local y
end

function random( number )
    return( rand() % number )
end

session = new ( "session" )
session.mimeType = ".gif"

// Path to INI file that will be used to keep the visitor count.
path = 'C:\MyDocuments\Imaging Dll\GDLibraryWrapper\counter.ini'

// Inside the .ini file it should look like this. 
//    [section]
//    key=value
cnt = 1 + iniGetStr( path, "count", "key", "0" )
retval = iniSetStr ( path, "count", "key", "" + cnt ) 
  
// register COM object
gdImage = new ( "com", "GDLibrary.gdImage" )

// Because we're gonna draw a gradient, we create a True Color image!
// GD Library will dither and convert it to a Palette on output!
gdImage.CreateTrueColor(300, 146)

// Load background image from file
if ( ! gdImage.LoadFromFile("C:\MyDocuments\Imaging Dll\GDLibraryWrapper\starbg-4.jpg") )
    session.response ( "Unable to load image!" )
end

// Image dimentions
height = 146
width = 300

// Add/Return Colors to Palette
Black = gdImage.ColorAllocate(0, 0, 0) // First color added will always be background color. Palette Index = 0
white = gdImage.ColorAllocate(255, 255, 255) // Palette Index = 1
    
//ctr = random(20)
ctr = 12
println ( "Grid Size: " + ctr )

// Draw a grid using lines.
for ( i = 0; i <= height; i += ctr)
    gdImage.Line(0, i, i, height, white)
end
for ( i = 0; i <= width; i += ctr)
    gdImage.Line(i, 0, width, i-100, white)
end

// Draw random Gradient!
gdImage.GradientFillRect(gdImage.ColorAllocate(random(255), random(255), random(255)), gdImage.ColorAllocate(random(255), random(255), random(255)), 110, 90, 185, 65, 0)

// Draw Text
tmp = random(50)
gdImage.Chars(gdImage.FontGetGiant(), 135, 70, cnt, White)

// Return a Jpg data stream
// Output the image to the browser.
session.response ( gdImage.ToJpegStream().Read ( -1 ) )

return  

// fglSourceLink( "copyright")
 
]>

Click here to view the FGL source code for this page...
http://www.fifthgensys.com
View Source