Clip a raster image boundary

AutoCAD ActiveX

 
Clip a raster image boundary
 
 
 

This example adds a raster image in model space. It then clips the image based on a clip boundary. This example uses the downtown.jpg file found in the sample directory. If you do not have this image, or if it is located in a different directory, insert a valid path and file name for the imageName variable.

Sub Ch10_ClippingRasterBoundary()
 Dim insertionPoint(0 To 2) As Double
 Dim scalefactor As Double
 Dim rotationAngle As Double
 Dim imageName As String
 Dim rasterObj As AcadRasterImage
    
 imageName = "C:\AutoCAD\sample\downtown.jpg"
 insertionPoint(0) = 5
 insertionPoint(1) = 5
 insertionPoint(2) = 0
 scalefactor = 2
 rotationAngle = 0
    
 On Error GoTo ERRORHANDLER
 ' Creates a raster image in model space
 Set rasterObj = ThisDrawing.ModelSpace.AddRaster _
 (imageName, insertionPoint, _
 scalefactor, rotationAngle)
 ZoomAll
 ' Establish the clip boundary with an array of points
 Dim clipPoints(0 To 9) As Double
 clipPoints(0) = 6: clipPoints(1) = 6.75
 clipPoints(2) = 7: clipPoints(3) = 6
 clipPoints(4) = 6: clipPoints(5) = 5
 clipPoints(6) = 5: clipPoints(7) = 6
 clipPoints(8) = 6: clipPoints(9) = 6.75
    
 ' Clip the image
 rasterObj.ClipBoundary clipPoints
    
 ' Enable the display of the clip
 rasterObj.ClippingEnabled = True
 ThisDrawing.Regen acActiveViewport
 Exit Sub
    
ERRORHANDLER:
 MsgBox Err.Description
End Sub