gpt4 book ai didi

c# - 使用 SizeMode ZOOM 从 Picturebox 中选取颜色

转载 作者:行者123 更新时间:2023-12-02 05:36:02 25 4
gpt4 key购买 nike

如何从 ZOOMed Picture 框中获取点(鼠标光标的位置)的颜色?

我当前的代码不起作用

Private Sub pickColor(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picBox.MouseClick
Dim TempBitmap As New Bitmap(picBox.Image)
Dim MyColor As Color
MyColor = TempBitmap.GetPixel(e.X, e.Y)
End Sub

最佳答案

你可以尝试这样的事情:

Private Sub pickColor(ByVal sender As Object, ByVal e As MouseEventArgs) _
Handles picBox.MouseClick
Using bmp As New Bitmap(picBox.ClientSize.Width, _
picBox.ClientSize.Height)
picBox.DrawToBitmap(bmp, picBox.ClientRectangle)
MessageBox.Show(bmp.GetPixel(e.X, e.Y).ToString())
End Using
End Sub

关于c# - 使用 SizeMode ZOOM 从 Picturebox 中选取颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11702387/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com