VB.NET2005计算图片的颜色信息
日期:2008-6-27 13:53:05 来源: 作者: 浏览:次 |
|
| VB.NET2005计算图片的颜色信息 |
Public Structure ColorInfo Dim color As String Dim r As Integer Dim g As Integer Dim b As Integer Dim count As Integer End Structure
Public Function GetCountColor(ByVal img As Image) As ColorInfo Dim f As New ColorInfo Dim bmp As Bitmap bmp = New Bitmap(img) Dim red, green, blue As Long With bmp For y As Integer = 0 To .Height - 1 For x As Integer = 0 To .Width - 1 Dim pixel As System.Drawing.Color pixel = .GetPixel(x, y) red += pixel.R green += pixel.G blue += pixel.B Next Next End With Dim temp As Integer = bmp.Height * bmp.Width f.r = red / temp | |