前一陣子看到這篇,跳了過去,但就是因為這樣讓自己轉了很大的一個彎
喔 應該說是跑到月球又跑了回來 -.-!!
利用矩陣的方式將色彩轉換
[R,G,B,A,1] X | 1 0 0 0 0|
| 0 1 0 0 0|
| 0 0 1 0 0|
| 0 0 0 1 0|
| 0 0 0 0 1|
每一Pixel 以 紅色 綠色 藍色 透明度表示 (但我不懂為何要5 X 5 4X4就好啦)
Use ColorMatrix do gray scale
Dim img As Image = Image.FromFile(dlg.FileName)
Dim bm As Bitmap = New Bitmap(img.Width, img.Height)
Dim g As Graphics = Graphics.FromImage(bm)
Dim cm As New Imaging.ColorMatrix(New Single()() _
{New Single() {0.3, 0.3, 0.3, 0, 0}, _
New Single() {0.59, 0.59, 0.59, 0, 0}, _
New Single() {0.11, 0.11, 0.11, 0, 0}, _
New Single() {0, 0, 0, 1, 0}, _
New Single() {0, 0, 0, 0, 1} _
})
Dim ia As ImageAttributes = New ImageAttributes()
ia.SetColorMatrix(cm)
g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, ia)
g.Dispose()
On internet almost use C#, althougth I found a code by VB.net. but some code error. -____-!!
I fixed it ................
- Aug 03 Tue 2010 22:24
Color Matrix
全站熱搜
留言列表
發表留言