BitmapRegion.vb
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
''' <summary>
''' 说明:图片轮廓类,通过这个类提供的方法得到图片的外围轮廓
''' 作者:周公
''' 原创地址:http://blog.csdn.net/zhoufoxcn
''' </summary>
Public Class BitmapRegion
Public Sub New()
End Sub
Public Shared Sub CreateControlRegion(ByVal control As Control, ByVal bitmap As Bitmap)
'如果控件或者图象为空
If control Is Nothing OrElse bitmap Is Nothing Then
Exit Sub
End If
'将控件设置成图象一样的尺寸
control.Width = bitmap.Width
control.Height = bitmap.Height
'如果处理的是一个窗体对象
If TypeOf control Is System.Windows.Forms.Form Then
Dim form As Form = TryCast(control, Form)
'强制转换为Form实例
'将窗体的尺寸设置成比图片稍微大一点,这样就不用显示窗体边框
form.Width += 15
form.Height += 35
'设置窗体无边框
form.FormBorderStyle = FormBorderStyle.None
'设置窗体背景
form.BackgroundImage = bitmap
'根据图片计算路径
Dim graphicsPath As GraphicsPath = CalculateControlGraphicsPath(bitmap)
'应用区域
form.Region = New Region(graphicsPath)
'如果处理的是一个按钮对象
ElseIf TypeOf control Is System.Windows.Forms.Button Then
Dim button As Button = TryCast(control, Button)
'强制转换为Button实例
'不显示文字
button.Text = ""
'当鼠标处在上方时更改光标状态
button.Cursor = Cursors.Hand
'设置背景图片
button.BackgroundImage = bitmap
'根据图片计算路径
Dim graphicsPath As GraphicsPath = CalculateControlGraphicsPath(bitmap)
'应用区域
button.Region = New Region(graphicsPath)
End If
End Sub
''' <summary>
''' 通过逼近的方式扫描图片的轮廓
后面还有 33 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
