[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 |