<%@ LANGUAGE = JScript%> <% // JavaScript Scripting Example 06 // // "Logotype" // // Dimac 2002-02-18 (www.dimac.net) var source; var destination; var x; var y; source = Request.Item("src"); destination = Request.Item("dest"); x = Request.Item("x"); y = Request.Item("y"); if ((!source) || (source == null)) source = "dimac.bmp"; if ((!destination) || (destination == null)) destination = "ball.jpg"; var errormsg = new String(""); errormsg = Logo(); // Check if errors occured if (errormsg != "") DisplayError(errormsg); // Center a text in the center of a large image function Logo() { try { var srcobj; var destobj; var top; var left; var path; // Fix path path = Server.MapPath("..\\..\\images") + "\\"; srcobj = Server.CreateObject("W3Image.Image"); destobj = Server.CreateObject("W3Image.Image"); // Load the source image if (srcobj.LoadImage(path + source) == false) { // Do your error handling here... return "Error when loading source image '" + source + "'. Path " + path + source + " is probably invalid."; } // Load the destination image if (destobj.LoadImage(path + destination) == false) { // Do your error handling here... return "Error when loading source image '" + destination + "'. Path " + path + destination + " is probably invalid."; } srcobj.StretchBltExt(destobj, x, y, srcobj.width, srcobj.height, 0, 0, srcobj.width, srcobj.height, "transparent"); if (destobj.StreamImage(Response, "JPG", 24) == false ) { // Do your error handling here... return "Error when streaming image!"; } // Success return ""; } catch (err) { // Do your error handling here... return "Error: " + (err.number & 0xFFFF) + " - " + err.description + "."; } } // Example of a error handler - Displaying the error as a image function DisplayError(msgcode) { // Create an error image var errorimage = Server.CreateObject("W3Image.Image"); errorimage.CreateEmptySurface(1,1); // Create and select the font var fontobj = errorimage.CreateFont("Tahoma",24,0,"normal",0,0x000000,false,false,true); errorimage.SetFont(fontobj); // Get size of the error message var width = errorimage.GetTextWidth(msgcode); var height = errorimage.GetTextHeight(msgcode); // Create a surface as large as the error message errorimage.CreateEmptySurface(width,height); // Select the font again (font is deselected when creating a new surface) errorimage.SetFont(fontobj); // Write the error message errorimage.DrawText(msgcode,0,0); // Stream the image containing the error message errorimage.StreamImage(Response, "JPG", 24); } %>