重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net如何输出图片 vbnet printdocument

vb 如何使部分窗体生成图片

只要将VB窗口内的需要部分保存成图片文件就可以了

民丰ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!

要用到API函数的:

Private Type POINTAPI

x As Long

y As Long

End Type

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 GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long

Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

Private Sub Command1_Click()

Dim hdc As Long

Dim sw As Integer

Dim sh As Integer

Dim CurPos As POINTAPI

Dim Cur As Long

Me.Hide

DoEvents

Picture1.AutoRedraw = True

hdc = GetDC(0)

GetCursorPos CurPos

Cur = GetCursor

Picture1.Width = Screen.Width

Picture1.Height = Screen.Height

sw = Screen.Width / Screen.TwipsPerPixelX

sh = Screen.Height / Screen.TwipsPerPixelY

BitBlt Picture1.hdc, 0, 0, sw, sh, hdc, 0, 0, vbSrcCopy

Me.Show

DrawIcon Picture1.hdc, CurPos.x - 10, CurPos.y - 10, Cur

ReleaseDC 0, hdc

Picture1.AutoRedraw = False

以下放到模块里:

Option Explicit

Type RECT_Type

left As Long

top As Long

right As Long

bottom As Long

End Type

'The following declare statements are case sensitive.

Declare Function GetActiveWindow Lib "User32" () As Long

Declare Function GetDesktopWindow Lib "User32" () As Long

Declare Sub GetWindowRect Lib "User32" (ByVal Hwnd As Long, _

lpRect As RECT_Type)

Declare Function GetDC Lib "User32" (ByVal Hwnd As Long) As Long

Declare Function CreateCompatibleDC Lib "Gdi32" (ByVal hdc As Long) _

As Long

Declare Function CreateCompatibleBitmap Lib "Gdi32" (ByVal hdc _

As Long, ByVal nWidth As Long, _

ByVal nHeight As Long) As Long

Declare Function SelectObject Lib "Gdi32" (ByVal hdc As Long, _

ByVal hObject As Long) As Long

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

Declare Function OpenClipboard Lib "User32" (ByVal Hwnd As Long) As Long

Declare Function EmptyClipboard Lib "User32" () As Long

Declare Function SetClipboardData Lib "User32" (ByVal wFormat As Long, _

ByVal hMem As Long) As Long

Declare Function CloseClipboard Lib "User32" () As Long

Declare Function ReleaseDC Lib "User32" (ByVal Hwnd As Long, _

ByVal hdc As Long) As Long

Declare Function DeleteDC Lib "Gdi32" (ByVal hdc As Long) As Long

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Global Const SRCCOPY = HCC0020

Global Const CF_BITMAP = 2

Function ScreenDump()

Dim AccessHwnd As Long, DeskHwnd As Long

Dim hdc As Long

Dim hdcMem As Long

Dim rect As RECT_Type

Dim junk As Long

Dim fwidth As Long, fheight As Long

Dim hBitmap As Long

' DoCmd.Hourglass True

'---------------------------------------------------

' Get window handle to Windows and Microsoft Access

'---------------------------------------------------

DoEvents

DeskHwnd = GetDesktopWindow()

AccessHwnd = GetActiveWindow()

'---------------------------------------------------

' Get screen coordinates of Microsoft Access

'---------------------------------------------------

Call GetWindowRect(AccessHwnd, rect)

fwidth = rect.right - rect.left

fheight = rect.bottom - rect.top

'---------------------------------------------------

' Get the device context of Desktop and allocate memory

'---------------------------------------------------

hdc = GetDC(DeskHwnd)

hdcMem = CreateCompatibleDC(hdc)

hBitmap = CreateCompatibleBitmap(hdc, fwidth, fheight)

If hBitmap 0 Then

junk = SelectObject(hdcMem, hBitmap)

'---------------------------------------------

' Copy the Desktop bitmap to memory location

' based on Microsoft Access coordinates.

'---------------------------------------------

junk = BitBlt(hdcMem, 0, 0, fwidth, fheight, hdc, rect.left, _

rect.top, SRCCOPY)

'---------------------------------------------

' Set up the Clipboard and copy bitmap

'---------------------------------------------

junk = OpenClipboard(DeskHwnd)

junk = EmptyClipboard()

junk = SetClipboardData(CF_BITMAP, hBitmap)

junk = CloseClipboard()

End If

'---------------------------------------------

' Clean up handles

'---------------------------------------------

junk = DeleteDC(hdcMem)

junk = ReleaseDC(DeskHwnd, hdc)

' DoCmd.Hourglass False

End Function

这里是拖动鼠标的框里内容截取,你也可以改成固定范围的截取。

vb.net如何把image类的变量以png格式导出

REM 假设存在Image类型变量img 

Dim bmp As Bitmap = CType(img, Bitmap) '先将Image类型强制转换为Bitmap类型 

bmp.Save("C:\1.png", System.Drawing.Imaging.ImageFormat.Png) '以PNG格式存储到C:\1.png

求大神指点vb.net 怎么以指定方式打开图片呢?

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

'建立新的系统进程    

Dim process As New System.Diagnostics.Process()

If RadioButton1.Checked Then

'设置文件名,此处为图片的真实路径+文件名    

process.StartInfo.FileName = "c:\a.bmp"

'设置进程运行参数    

process.StartInfo.Arguments = "rundll32.exe shimgvw.dll"

Else

process.StartInfo.FileName = "mspaint.exe"

process.StartInfo.Arguments = "c:\a.bmp"

End If

'此项为是否使用Shell执行程序,因系统默认为true,此项也可不设,但若设置必须为true    

'process.StartInfo.UseShellExecute = True

'此处可以更改进程所打开窗体的显示样式,可以不设    

'process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden

process.Start()

process.Close()

End Sub

VB.NET中如何使两个PictureBox显示指定相对应的图片?

用一个全局变量保存这个1.jpg,如变量a,你按按钮2时,可以简单的在a中插入一个"A",如a.SubString(0, a.Length-4) "A" a.SubString(a.Length-4),这样就能把例如"C:/Images/1.jpg"变成"C:/Images/1A.jpg"


名称栏目:vb.net如何输出图片 vbnet printdocument
当前路径:http://cqcxhl.com/article/dohiecc.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP