📄 form1.vb
字号:
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Public Class Form1
Inherits System.Windows.Forms.Form
Private g As Graphics
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(24, 16)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(288, 224)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 256)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(248, 16)
Me.Label1.TabIndex = 3
Me.Label1.Text = "鼠标点击点的RGB值:"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(336, 285)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.PictureBox1)
Me.Name = "Form1"
Me.Text = "获取图片颜色值"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub PictureBox1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles PictureBox1.MouseDown
g = Me.PictureBox1.CreateGraphics()
Dim newbitmap As Bitmap
newbitmap = Me.PictureBox1.Image
Dim tempcolor As Color
tempcolor = newbitmap.GetPixel(e.X, e.Y)
Dim tempstr As String = ""
tempstr = "(" + CType(CType(tempcolor.R, Integer), String) + ","
tempstr += CType(CType(tempcolor.G, Integer), String) + ","
tempstr += CType(CType(tempcolor.B, Integer), String) + ")"
Me.Label1.Text = "鼠标点击点的RGB值:" + tempstr
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -