指定特定黑白图像的透明度是打开还是关闭。 支持的平台:仅窗口 属性值只读:不 类型:布尔
言论黑白光栅图像是仅由前景色和背景色组成的图像。附加黑白图像时,整个图像将继承颜色的当前图层设置。除了可以对任何附加图像进行修改之外,您还可以通过打开和关闭背景的透明度来修改黑白图像。 注意:黑白图像和黑白图像边界始终是相同的颜色。
例子工 务 局: Sub Example_Transparency()
' This example inserts a raster image and finds the current status
' of Transparency for the image. It then changes the Transparency
' status of the image.
' This example uses the "2d Projected Polylines.jpg" found in the sample
' directory. If you do not have the image, or it is located
' in a different directory, insert a valid path and name for the
' imageName variable below.
Dim insertionPoint(0 To 2) As Double
Dim scalefactor As Double
Dim rotAngleInDegree As Double, rotAngle As Double
Dim imageName As String
Dim raster As AcadRasterImage
imageName = "C:\AutoCAD\sample\2d Projected Polylines.jpg"
insertionPoint(0) = 2#: insertionPoint(1) = 2#: insertionPoint(2) = 0#
scalefactor = 1#
rotAngleInDegree = 0#
rotAngle = rotAngleInDegree * 3.141592 / 180#
On Error Resume Next
' Creates a raster image in model space
Set raster = ThisDrawing.ModelSpace.AddRaster(imageName, insertionPoint, scalefactor, rotAngle)
If Err.Description = "Filer error" Then
MsgBox imageName & " could not be found."
Exit Sub
End If
' Find the current Transparency
ThisDrawing.Regen True
MsgBox "The Transparency is currently set to: " & raster.transparency, vbInformation
' Change the Transparency
If (raster.transparency) Then
raster.transparency = False
Else
raster.transparency = True
End If
ThisDrawing.Regen True
MsgBox "The Transparency is now set to: " & raster.transparency, vbInformation
End Sub
Visual LISP: (vl-load-com)
(defun c:Example_Transparency()
;; This example inserts a raster image and finds the current status
;; of Transparency for the image. It then changes the Transparency
;; status of the image.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; This example uses the "2d Projected Polylines.jpg" found in the sample
;; directory. If you do not have the image, or it is located
;; in a different directory, insert a valid path and name for the
;; imageName variable below.
(setq insertionPoint (vlax-3d-point 2 2 0)
imageName ".\\Sample\\VBA\\2d Projected Polylines.jpg"
scalefactor 1
rotAngle (/ (* 0 3.141592) 180))
(if (/= (findfile imageName) nil)
(progn
;; Creates a raster image in model space
(setq modelSpace (vla-get-ModelSpace doc))
(setq raster (vla-AddRaster modelSpace (findfile imageName) insertionPoint scalefactor rotAngle))
(vla-ZoomExtents acadObj)
;; Find the current Transparency
(vla-Regen doc :vlax-true)
(alert (strcat "The Transparency is currently set to: " (if (= (vla-get-Transparency raster) :vlax-true) "True" "False")))
;; Change the Transparency
(vla-put-Transparency raster (if (= (vla-get-Transparency raster) :vlax-true) :vlax-false :vlax-true))
(vla-Regen doc :vlax-true)
(alert (strcat "The Transparency is currently now set to: " (if (= (vla-get-Transparency raster) :vlax-true) "True" "False")))
)
(alert (strcat imageName " could not be found."))
)
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 05:55
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.