VB.NET中的BitBlt 问题 50
PublicClassForm1ConstNOTSRCCOPY=&H33008ConstNOTSRCERASE=&H1100A6PrivateConstSRCAND=&H...
Public Class Form1
Const NOTSRCCOPY = &H33008
Const NOTSRCERASE = &H1100A6
Private Const SRCAND = &H8800C6
Private Const SRCCOPY = &HCC0020
Private Const SRCERASE = &H440328
Private Const SRECINVERT = &HEE0086
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim ret As Long
Dim hdc2 As IntPtr
Dim hdc1 As IntPtr
Dim i, j As Integer
hdc2 = Me.PictureBox2.CreateGraphics.GetHdc
hdc1 = Me.PictureBox1.CreateGraphics.GetHdc
Dim w As Integer
Dim h As Integer
w = Me.PictureBox1.Size.Width
h = Me.PictureBox1.Size.Height
i = w / 2
j = h / 2
While (i > 0)
ret = BitBlt(hdc2, i, j, w - 2 * i, h - 2 * j, hdc1, i, j, SRCCOPY)
i = i - 2
j = j - 2 * h / w
End While
Me.Text = ret
End Sub
函数执行成功 可是PIctureBox2就是不显示图形 求助高手啊。。。。急 展开
Const NOTSRCCOPY = &H33008
Const NOTSRCERASE = &H1100A6
Private Const SRCAND = &H8800C6
Private Const SRCCOPY = &HCC0020
Private Const SRCERASE = &H440328
Private Const SRECINVERT = &HEE0086
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim ret As Long
Dim hdc2 As IntPtr
Dim hdc1 As IntPtr
Dim i, j As Integer
hdc2 = Me.PictureBox2.CreateGraphics.GetHdc
hdc1 = Me.PictureBox1.CreateGraphics.GetHdc
Dim w As Integer
Dim h As Integer
w = Me.PictureBox1.Size.Width
h = Me.PictureBox1.Size.Height
i = w / 2
j = h / 2
While (i > 0)
ret = BitBlt(hdc2, i, j, w - 2 * i, h - 2 * j, hdc1, i, j, SRCCOPY)
i = i - 2
j = j - 2 * h / w
End While
Me.Text = ret
End Sub
函数执行成功 可是PIctureBox2就是不显示图形 求助高手啊。。。。急 展开
2个回答
展开全部
可能这是我见过的最成功VBnet的BITBLT示例。
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.PictureBox1.Image = Image.FromFile("E:\程序语言\VBpic\输入文件名.BMP")
End Sub
运行,点击你的Button2按钮(窗体Form1上加两个图片框和一个命令按钮搞成Button2)
PictureBox2就有受控的图片出来了。
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.PictureBox1.Image = Image.FromFile("E:\程序语言\VBpic\输入文件名.BMP")
End Sub
运行,点击你的Button2按钮(窗体Form1上加两个图片框和一个命令按钮搞成Button2)
PictureBox2就有受控的图片出来了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询