剪裁光栅图像边界
From AutoCAD ActiveX/VBA
本例在模型空间中添加光栅图像,然后根据剪裁边界来剪裁图像。本例使用 sample 目录中的 downtown.jpg 文件。如果没有此图像,或者此图像位于其他目录中,请为 imageName 变量插入有效的路径和文件名。
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) = 5insertionPoint(1) = 5insertionPoint(2) = 0scalefactor = 2rotationAngle = 0On Error GoTo ERRORHANDLER' 在模型空间中创建光栅图像Set rasterObj = ThisDrawing.ModelSpace.AddRaster _(imageName, insertionPoint, _scalefactor, rotationAngle)ZoomAll' 使用点数组建立剪裁边界Dim clipPoints(0 To 9) As DoubleclipPoints(0) = 6: clipPoints(1) = 6.75clipPoints(2) = 7: clipPoints(3) = 6clipPoints(4) = 6: clipPoints(5) = 5clipPoints(6) = 5: clipPoints(7) = 6clipPoints(8) = 6: clipPoints(9) = 6.75' 剪裁图像rasterObj.ClipBoundary clipPoints' 启用剪裁显示rasterObj.ClippingEnabled = TrueThisDrawing.Regen acActiveViewportExit SubERRORHANDLER:MsgBox Err.DescriptionEnd Sub