vb截图保存的问题
Me.AutoRedraw=TrueBitBltMe.hDC,sux,suy,picWidth,picHeight,GetDC(0),sux,suy,vbSrcCopyS...
Me.AutoRedraw = True
BitBlt Me.hDC, sux, suy, picWidth, picHeight, GetDC(0), sux, suy, vbSrcCopy
SavePicture Me.Image, "D:\gua\pic\1.jpg"
怎么保存出来的图片会是这样?
sux,suy是要截图片左上端的坐标```已定义
程序主要是要截取指定的屏幕(非全屏),并保存到文件。 展开
BitBlt Me.hDC, sux, suy, picWidth, picHeight, GetDC(0), sux, suy, vbSrcCopy
SavePicture Me.Image, "D:\gua\pic\1.jpg"
怎么保存出来的图片会是这样?
sux,suy是要截图片左上端的坐标```已定义
程序主要是要截取指定的屏幕(非全屏),并保存到文件。 展开
3个回答
展开全部
窗体的Image属性就是一个全屏图像。
用 图片框 存图像,再保存。添加一个 Picture1
Me.AutoRedraw = True
Me.ScaleMode = 3
With Picture1
.AutoRedraw = True
.BorderStyle = 0
.Width = picWidth
.Height = picHeight
.Visible = False
.PaintPicture Me.Image, 0, 0
BitBlt .hdc, sux, suy, picWidth, picHeight, GetDC(0), sux, suy, vbSrcCopy
SavePicture .Image, "D:\gua\pic\1.jpg"
End With
'SavePicture保存的图片是bmp格式,与扩展名无关。
用 图片框 存图像,再保存。添加一个 Picture1
Me.AutoRedraw = True
Me.ScaleMode = 3
With Picture1
.AutoRedraw = True
.BorderStyle = 0
.Width = picWidth
.Height = picHeight
.Visible = False
.PaintPicture Me.Image, 0, 0
BitBlt .hdc, sux, suy, picWidth, picHeight, GetDC(0), sux, suy, vbSrcCopy
SavePicture .Image, "D:\gua\pic\1.jpg"
End With
'SavePicture保存的图片是bmp格式,与扩展名无关。
展开全部
sux 和 suy 是什么?你要保存桌面场景的什么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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 Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Sub Command1_Click()
Dim pic As PictureBox
Set pic = Me.Controls.Add("VB.PictureBox", "pic1")
pic.AutoRedraw = True
pic.BorderStyle = 0
Dim dc As Long
dc = GetDC(0)
Dim sux As Integer, suy As Integer
Dim picWidth As Integer, picHeight As Integer
sux = 300
suy = 300
picWidth = 300
picHeight = 300
pic.Width = picWidth * Screen.TwipsPerPixelX
pic.Height = picHeight * Screen.TwipsPerPixelY
Call BitBlt(pic.hdc, 0, 0, picWidth, picHeight, dc, sux, suy, vbSrcCopy)
'Me.AutoRedraw = True
'Set Me.Picture = pic.Image
SavePicture pic.Image, "c:\test.bmp"
ReleaseDC 0, dc
Me.Controls.Remove "pic1"
Set pic = Nothing
End Sub
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Sub Command1_Click()
Dim pic As PictureBox
Set pic = Me.Controls.Add("VB.PictureBox", "pic1")
pic.AutoRedraw = True
pic.BorderStyle = 0
Dim dc As Long
dc = GetDC(0)
Dim sux As Integer, suy As Integer
Dim picWidth As Integer, picHeight As Integer
sux = 300
suy = 300
picWidth = 300
picHeight = 300
pic.Width = picWidth * Screen.TwipsPerPixelX
pic.Height = picHeight * Screen.TwipsPerPixelY
Call BitBlt(pic.hdc, 0, 0, picWidth, picHeight, dc, sux, suy, vbSrcCopy)
'Me.AutoRedraw = True
'Set Me.Picture = pic.Image
SavePicture pic.Image, "c:\test.bmp"
ReleaseDC 0, dc
Me.Controls.Remove "pic1"
Set pic = Nothing
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询