作者SmallBeeWayn (喵喵叫的蜜蜂猫)
看板Visual_Basic
标题[.NET] 色相转换?
时间Sun May 26 17:56:17 2013
请输入专案类型(网站专案或者应用程式专案): Visual Studio 2012
想做出一个色相转换矩阵,输入径度然後把图片转色相(HUE)
可是实际转换结果是错的,例如白色怎麽转应该都是白的
可是却会变 白->黄->绿->淡蓝->白
矩阵是网路找来的,理论上不应该错,比较担心是径度、角度之间转换的问题
程式码如下:
Friend Const hueRdef = 0.213
Friend Const hueGdef = 0.715
Friend Const hueBdef = 0.072
Private att As New Imaging.ImageAttributes
~~~~~~~~~~~~~~~~~~~~
Dim aCos = Math.Abs((Now.Second+Now.Millisecond/1000) Mod 10 - 5) * Math.PI
Dim aSin = Math.Sin(aCos)
aCos = Math.Cos(aCos)
Dim cmT As New ColorMatrix(New Single()() { _
New Single() {
hueRdef + aCos * (1 - hueRdef) - aSin * hueRdef
, hueGdef - aCos * hueGdef - aSin * hueGdef
, hueBdef - aCos * hueBdef + aSin * (1 - hueBdef), 0, 0}, _
New Single() {
hueRdef - aCos * hueRdef + aSin * 0.143
, hueGdef + aCos * (1 - hueGdef) + aSin * 0.14
, hueBdef - aCos * hueBdef - aSin * 0.283, 0, 0}, _
New Single() {
hueRdef - aCos * hueRdef - aSin * (1 - hueRdef)
, hueGdef - aCos * hueGdef + aSin * hueGdef
, hueBdef + aCos * (1 - hueBdef) + aSin * hueBdef, 0, 0}, _
New Single() {0, 0, 0, 1, 0}, _
New Single() {0, 0, 0, 0, 1}})
att.SetColorMatrix(cmT)
bG.DrawImage(img, rect, x, y, w, h, GraphicsUnit.Pixel, att)
--
单选题: 请问...从天上掉下来的是?
1.魔法国 2.陨石 3.来自未来的少女 4.娱乐用人型天使
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.248.203.171