CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

TrueColorImages Property (ActiveX)

2023-1-3 02:42| 发布者: admin| 查看: 219| 评论: 0|来自: AutoCAD

摘要: 确定光栅和渲染图像是以真彩色还是托盘彩色显示。

确定光栅和渲染图像是以真彩色还是托盘彩色显示。

支持的平台:仅窗口

签名

工 务 局:

object.TrueColorImages
对象

类型:首选项显示

此属性适用的对象。

属性值

只读:

类型:布尔

  • True:以操作系统所能达到的最高颜色分辨率显示光栅和渲染图像。
  • False:以调色板颜色显示光栅和渲染图像。

言论

此属性的初始值为 False。

例子

工 务 局:

Sub Example_TrueColorImages()
    ' This example reads and modifies the preference value which determines
    ' if raster and render images are displayed at True Color or palletized color.
    ' When finished, this example resets the preference value back to
    ' it's original value.
    '
    ' This example uses the "2d Projected Polylines.jpg" found in the sample
    ' directory. If you do not have this image, or it is located
    ' in a different directory, insert a valid path and file name
    ' for the imageName variable below.
    
    Dim ACADPref As AcadPreferencesDisplay
    Dim originalValue As Variant, newValue As Variant
    Dim insertionPoint(0 To 2) As Double
    Dim scalefactor As Double, rotationAngle As Double
    Dim imageName As String
    Dim rasterObj As AcadRasterImage
    
    imageName = "c:\AutoCAD\sample\2d Projected Polylines.jpg"
    
    ' Define Raster object
    insertionPoint(0) = 5: insertionPoint(1) = 5: insertionPoint(2) = 0
    scalefactor = 5#: rotationAngle = 0
    
    On Error GoTo ERRORTRAP
    
    ' Loads a raster image into model space
    Set rasterObj = ThisDrawing.ModelSpace.AddRaster(imageName, insertionPoint, scalefactor, rotationAngle)
    ThisDrawing.Application.ZoomAll
    
    ' Get the display preferences object
    Set ACADPref = ThisDrawing.Application.Preferences.Display
    
    ' Read and display the original value
    originalValue = ACADPref.TrueColorImages
    MsgBox "The TrueColorImages preference is set to: " & originalValue

    ' Modify the TrueColorImages preference by toggling the value
    ACADPref.TrueColorImages = Not (originalValue)
    newValue = ACADPref.TrueColorImages
    ThisDrawing.Regen acAllViewports
    
    MsgBox "The TrueColorImages preference has been set to: " & newValue

    ' Reset the preference back to it's original value
    '
    ' * Note: Comment out this last section to leave the change to
    '         this preference in effect
    ACADPref.TrueColorImages = originalValue
    ThisDrawing.Regen acAllViewports
    
    MsgBox "The TrueColorImages preference was reset back to: " & originalValue

    Exit Sub
    
    ' If you got an error (most likely a problem with the file path),
    ' then display an error message
ERRORTRAP:
    If Err.Description <> "" Then
        MsgBox Err.Description
    End If
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_TrueColorImages()
    ;; This example reads and modifies the preference value which determines
    ;; if raster and render images are displayed at True Color or palletized color.
    ;; When finished, this example resets the preference value back to
    ;; it's original value.
    ;;
    ;; This example uses the "2d Projected Polylines.jpg" found in the sample
    ;; directory. If you do not have this image, or it is located
    ;; in a different directory, insert a valid path and file name
    ;; for the imageName variable below.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Define Raster object
    (setq insertionPoint (vlax-3d-point 5 5 0)
          imageName ".\\Sample\\VBA\\2d Projected Polylines.jpg"
          scalefactor 5
          rotationAngle 0)

    (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 rotationAngle))
            (vla-ZoomExtents acadObj)

            ;; Get the display preferences object
            (setq ACADPref (vla-get-Display (vla-get-Preferences acadObj)))
    
            ;; Read and display the original value
            (setq originalValue (vla-get-TrueColorImages ACADPref))
            (alert (strcat "The TrueColorImages preference is set to: " (if (= originalValue :vlax-true) "True" "False")))

            ;; Modify the TrueColorImages preference by toggling the value
            (vla-put-TrueColorImages ACADPref (if (= originalValue :vlax-true) :vlax-false :vlax-true))
            (vla-Regen doc acAllViewports)
    
            (alert (strcat "The TrueColorImages preference has been set to: " (if (= (vla-get-TrueColorImages ACADPref) :vlax-true) "True" "False")))

            ;; Reset the preference back to it's original value
            ;;
            ;; * Note: Comment out this last section to leave the change to
            ;;         this preference in effect
            (vla-put-TrueColorImages ACADPref originalValue)
            (vla-Regen doc acAllViewports)
    
            (alert (strcat "The TrueColorImages preference was reset back to: " (if (= (vla-get-TrueColorImages ACADPref) :vlax-true) "True" "False")))
	       )
        (alert (strcat imageName " could not be found."))
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-11 20:24

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部