Creating and Pasting a Region (ASP - VBScript)

The following example demonstrates the creation of regions in LEADTOOLS. It uses two LEADRaster objects. It loads an image in the first one and creates an elliptical region in it. It then pastes this region onto the second LEADRaster object and displayes the pasted region.

<%@ Language=VBScript %>
<%Option Explicit%>
<%
      Dim RasterObj
      Dim RasterObj2
      Dim RasterIO
      Dim RasterProc

      Dim FILE_JFIF
      Dim SAVE_OVERWRITE
      Dim L_RGN_SET
      Dim CB_DST_0 
      Dim CB_OP_ADD

      SAVE_OVERWRITE = 0
      FILE_JFIF = 10
      L_RGN_SET = 1
      CB_DST_0 = 32
      CB_OP_ADD = 768

      Set RasterObj = Server.CreateObject("LEADRaster.LEADRaster")
      Set RasterObj2 = Server.CreateObject("LEADRaster.LEADRaster")
      Set RasterIO = Server.CreateObject("LEADRasterIO.LEADRasterIO")
      Set RasterProc = Server.CreateObject("LEADRasterProcess.LEADRasterProcess")

      RasterIO.Load RasterObj, "i:\a\pic\20020816demo3.jpg", 0, 0, 1

      'Create the region
      RasterObj.SetRgnEllipse 0, 0, RasterObj.BitmapWidth, RasterObj.BitmapHeight / 2, L_RGN_SET

      'Create a blank bitmap so that we can "paste" the region onto it
      RasterObj2.CreateBitmap RasterObj.RgnWidth, RasterObj.RgnHeight, RasterObj.BitmapBits
      RasterProc.Fill RasterObj2, RGB(0, 255, 255)

      'Paste the region
      RasterProc.Combine RasterObj2, 0, 0, RasterObj.RgnWidth, RasterObj.RgnHeight, RasterObj, RasterObj.RgnLeft, RasterObj.RgnTop, CB_DST_0 + CB_OP_ADD

      RasterIO.Save RasterObj2, "c:\asp.jpg", FILE_JFIF, 0, 2, 0
      Response.Write "<IMG SRC='c:\asp.jpg'>"
%>