明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2631|回复: 4

[.net群] 2013-06-08 明经 AutoCAD.NetApi (2474812) 群聊记录:请教真彩色和配色系统颜色如何转为索引颜色?

 关闭 [复制链接]
发表于 2013-6-8 11:17 | 显示全部楼层 |阅读模式
[C#]有心人问道 11:17:33
请教真彩色和配色系统颜色如何转为索引颜色?
[C#]有心人问道 11:18:29
或是我怎么知道在[qqimg]oldimg/{7B41DEE2-0791-94A7-312C-D541AF2CAA93}.jpg[/qqimg]这里面选择的颜色属于那一种系统?
[VB.net]福萝卜 11:21:59
可是有的真色彩没有对应的索引色啊
[vb.net]好吧 11:22:24
本来索引色就少没有很正常
黑白照还只有灰度呢= =
[VB.net]福萝卜 11:22:51
Function ACI2RGB(ByVal ACI As Single, ByVal Red As Single, ByVal Green As Single, ByVal Blue As Single) As Color
        Dim nbr As Double
        nbr = Microsoft.VisualBasic.Right(ACI, 1) / 2
        Dim bolAdd As Boolean, intBase As Integer
        Select Case ACI


            Case Is < 10 : GoTo SkipCalc
            Case Is < 60 : bolAdd = True : intBase = 1
            Case Is < 90 : bolAdd = False : intBase = 6
            Case Is < 140 : bolAdd = True : intBase = 9
            Case Is < 170 : bolAdd = False : intBase = 14
            Case Is < 220 : bolAdd = True : intBase = 17
            Case Is < 250 : bolAdd = False : intBase = 22
            Case Is < 256 : GoTo SkipCalc
      lC = ((2 * nbr) Mod 2) * 0.5 * dblA
SkipCalc:
        Select Case ACI


            Case 1 : Red = 255 : Green = 0 : Blue = 0
            Case 2 : Red = 255 : Green = 255 : Blue = 0
            Case 3 : Red = 0 : Green = 255 : Blue = 0
            Case 4 : Red = 0 : Green = 255 : Blue = 255
            Case 5 : Red = 0 : Green = 0 : Blue = 255
            Case 6 : Red = 255 : Green = 0 : Blue = 255
            Case 7, 8, 9
                Red = 0 : Green = 0 : Blue = 0
            Case Is < 60
                Red = 255 * dblA : Green = 255 * dblB : Blue = 255 * dblC
            Case Is < 90
                Red = 255 * dblB : Green = 255 * dblA : Blue = 255 * dblC
            Case Is < 140
       Case Else
                MsgBox("Invalid ACI number (0-255 valid).")
                Exit Function
        End Select
        Dim dblStart As Double
        If bolAdd Then


            dblStart = IIf(nbr = Int(nbr), 0, 0.5)
        Else : dblStart = IIf(nbr = Int(nbr), 0.75, 0.875)
        End If
        Dim intSign As Integer, dblFactor As Double
        intSign = IIf(bolAdd, 1, -1)
        dblFactor = IIf(nbr = Int(nbr), 0.25, 0.125)
        Dim dblA As Double, dblB As Double, dblC As Double
        dblA = Choose(Fix(nbr) + 1, 1, 0.65, 0.5, 0.3, 0.15)
        dblB = (dblStart + intSign * (Microsoft.VisualBasic.Left(ACI, Len(CStr(ACI)) - 1) - intBase) * dblFactor) * dblA
        db               Red = 255 * dblC : Green = 255 * dblA : Blue = 255 * dblB
            Case Is < 170
                Red = 255 * dblC : Green = 255 * dblB : Blue = 255 * dblA
            Case Is < 220
                Red = 255 * dblB : Green = 255 * dblC : Blue = 255 * dblA
            Case Is < 250
                Red = 255 * dblA : Green = 255 * dblC : Blue = 255 * dblB
            Case Is < 256
                Red = 255 * Choose(nbr * 2 + 1, 0.33, 0.464, 0.598, 0.732, 0.866, 1)
                Green = Red : Blue = Red
        End Select
        ACI2RGB = Color.FromArgb(Red, Green, Blue)
    End Function
 楼主| 发表于 2013-6-8 11:34 | 显示全部楼层
[C#]猴子 11:34:54
http://www.amazon.cn/AutoCAD-VBA ... E%E6%B4%AA%E9%A3%9E
AutoCADVBA&VB.NET开发基础与实例教程 (C#版)
[C#]猴子 11:35:29
好像库存比较少
 楼主| 发表于 2013-6-8 11:54 | 显示全部楼层
vb.net叶子 11:54:06
第二版跟第一版有什么区别
[C#]猴子 12:00:42
第一版是用VB.net写的
第二版是C#
 楼主| 发表于 2013-6-8 13:51 | 显示全部楼层
[C#]有心人问道 13:51:44
[qqimg]oldimg/{08852D99-653F-606F-22F6-CDD5113AF4A0}.jpg[/qqimg]朋友,你这个方法是做什么用的?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-29 02:08 , Processed in 0.237350 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表