伙计们,我需要检索图像的颜色..如何检索它?操纵图像
Q
操纵图像
1
A
回答
1
如果您将图像加载到Bitmap类(System.Drawing.Bitmap), 中,则可以使用GetPixel()方法检索单个像素的颜色。
1
你可以使用Bitmap.GetPixel
0
一定像素的颜色有一些很好的信息在这里:http://www.bobpowell.net/faqmain.htm
1
其实,这是VB.NET,但使用它转换为C#http://www.developerfusion.com/tools/convert/vb-to-csharp/
Private Sub btnOverlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOverlay.Click
Dim rgbColour = New Color
Dim bmpPicture As Bitmap = Nothing
Dim bmpPicture_Negative As Bitmap = Nothing
Try
bmpPicture = New Bitmap("/root/Desktop/head.jpg")
bmpPicture_Negative = New Bitmap("/root/Desktop/head.jpg")
Catch ex As Exception
MsgBox("One of the images is not present.")
End Try
Dim rectPicSize As System.Drawing.RectangleF = bmpPicture.GetBounds(System.Drawing.GraphicsUnit.Pixel)
Dim iMaxX As Integer = CInt(rectPicSize.Width)
Dim iMaxY As Integer = CInt(rectPicSize.Height)
Dim iYindex As Integer = 0
Dim iXindex As Integer = 0
For iYindex = 0 To iMaxY - 1 Step 1
For iXindex = 0 To iMaxX - 1 Step 1
rgbColour = bmpPicture.GetPixel(iXindex, iYindex)
rgbColour = Color.FromArgb(255 - rgbColour.R, 255 - rgbColour.G, 255 - rgbColour.B)
bmpPicture_Negative.SetPixel(iXindex, iYindex, rgbColour)
Next iXindex
Next iYindex
Dim strHTMLColor As String = System.Drawing.ColorTranslator.ToHtml(rgbColour)
TextBox1.Text = Nothing
TextBox1.Text = "R: "
TextBox1.Text += rgbColour.R.ToString() + vbCrLf
TextBox1.Text += "G: " + rgbColour.G.ToString() + vbCrLf
TextBox1.Text += "B: " + rgbColour.B.ToString() + vbCrLf
TextBox1.Text += "HTML: " + strHTMLColor + vbCrLf
PictureBox1.Image = bmpPicture
PictureBox2.Image = bmpPicture_Negative
'bmpPicture.Dispose()
End Sub
相关问题
- 1. 图像操纵的jquery PHP
- 2. 笨图像操纵问题
- 3. SVG图像互相操纵
- 4. 使用WPF操纵图像
- 5. Xcode图像/像素操纵实时
- 6. PHP,操纵图像和缩略图?
- 7. 图片操纵 - 强度和TIF图像
- 8. 操纵位图图像存储与Linux
- 9. 操纵图像而不保存它
- 10. 操纵与ImageMagick库图像笨
- 11. 用于操纵图像文本与GD
- 12. 使用java来操纵图像
- 13. 图像失去对操纵画布
- 14. 经典ASP图像(PNG)操纵
- 15. 可以使用画布操纵图像
- 16. 使用Graphics2D操纵图像多次
- 17. 操纵一个图像到几个
- 18. 当我操纵它时显示图像
- 19. 操纵画布上的图像
- 20. 操纵.gif图片
- 21. HTML5画布像素操纵
- 22. 钛Appcelerator操纵图像与其他文字和其他图像
- 23. 试图操纵使用Python
- 24. 无法操纵2D图
- 25. 操纵scale_fill_gradient2的图例
- 26. Angular2操纵ngModel视图
- 27. VBA图表操纵慢
- 28. 用C#ASP.NET图表操纵
- 29. SDL2与操纵像素和SDL_UpdateTexture混淆图像
- 30. 在C#中的像素级别操纵图像