vb.net窗体保存图片 vb窗体保存的文件
vb.net 2008 如何将指定的窗体截图并保存
INTOUCH自带的就有,打印屏幕的命令
成都创新互联是一家集网站建设,王屋企业网站建设,王屋品牌网站建设,网站定制,王屋网站建设报价,网络营销,网络优化,王屋网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
自己写个时间条件运行那命令就可以了
PRINTSCREEN这个命令 具体怎么用 看下帮助
希望我的回答对你有所帮助
如有其他问题,可以继续追问,您的采纳是我前进的动力!
vb.net 如何保存当前页为图片
提供两个思路
用printscreen,将其保存到文件,再调用outlook发出去,但是您说的超出一屏,就麻烦了;
以下代码保存为文件,引用自MSDN,由于我的SD版本不支持我的outlook,所以暂时无法给发送邮件的例子,请参考吧!
system.Windows.Forms.SendKeys.Send("%{PRTSC}")
If Not System.Windows.Forms.Clipboard.GetDataObject() Is Nothing Then
Dim oDataObj As IDataObject = System.Windows.Forms.Clipboard.GetDataObject()
If oDataObj.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then
Dim oImgObj As System.Drawing.Image = oDataObj.GetData(DataFormats.Bitmap, True)
'To Save as Bitmap
oImgObj.Save("F:\Test.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
'To Save as Jpeg
oImgObj.Save("D:\Test.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
'To Save as Gif
oImgObj.Save("d:\Test.gif", System.Drawing.Imaging.ImageFormat.Gif)
End If
End If
2.另外出出报表,再调用outlook发出去,只给出数据性报表,而不一定是窗体本身;
如何在VB中保存图片
VB6.0可使用SavePicture 语句来保存窗体或图像框中经修改的图片。
1)SavePicture 语句,从对象或控件(如果有一个与其相关)的 Picture 或 Image 属性中将图形保存到文件中。
说明:无论在设计时还是运行时图形从文件加载到对象的 Picture
属性,而且它是位图、图标、元文件或增强元文件,则图形将以原始文件同样的格式保存。如果它是 GIF 或 JPEG 文件,则将保存为位图文件。
2)AutoRedraw 属性,返回或设置从图形方法到持久图形的输出。
该属性为True,可使 Form 对象或 PictureBox
控件的自动重绘有效。图形和文本输出到屏幕,并存储在内存的图象中。该对象不接受绘制事件,必要时,用存储在内存中的图象进行重绘。
以下代码保存窗体装载并进行文字修饰的图片:
Option Explicit
Private Sub Command1_Click()
SavePicture Image, App.Path "\TEST" ' 将图片保存到文件。
End Sub
Private Sub Form_Click()
FontSize = 24
Print " 将图片保存到文件"
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
End Sub
3)若要保存为JPG图片需要采取使用API函数实现。参考以下步骤和代码:
a.在图片框加载需要添加文字水印的图片。
b.使用如下代码实现添加文字到图片框。
Private Sub CmdEdit_Click() '修改
Dim strTxt As String
strTxt = "风雨无阻 拍摄"
Picture1.FontSize = 18
Picture1.CurrentY = Picture1.ScaleHeight - 30
Picture1.CurrentX = Picture1.ScaleWidth / 2 - Picture1.TextWidth(strTxt) / 2
Picture1.ForeColor = vbWhite
Picture1.FontItalic = True
Picture1.Print strTxt
End Sub
c.将以下API转换图片格式代码放置于标准模块,模块命名为saveApg。
Option Explicit
Public Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Public Type GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type
Public Type EncoderParameter
GUID As GUID
NumberOfValues As Long
type As Long
Value As Long
End Type
Public Type EncoderParameters
Count As Long
Parameter As EncoderParameter
End Type
Public Declare Function GdiplusStartup Lib "GDIPlus" (token As Long, inputbuf As GdiplusStartupInput, ByVal outputbuf As Long) As Long
Public Declare Function GdiplusShutdown Lib "GDIPlus" (ByVal token As Long) As Long
Public Declare Function GdipCreateBitmapFromHBITMAP Lib "GDIPlus" (ByVal hbm As Long, ByVal hpal As Long, Bitmap As Long) As Long
Public Declare Function GdipDisposeImage Lib "GDIPlus" (ByVal Image As Long) As Long
Public Declare Function GdipSaveImageToFile Lib "GDIPlus" (ByVal Image As Long, ByVal fileName As Long, clsidEncoder As GUID, encoderParams As Any) As Long
Public Declare Function CLSIDFromString Lib "ole32" (ByVal str As Long, id As GUID) As Long
Public Declare Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal fileName As Long, Bitmap As Long) As Long
Public Function PictureBoxSaveJPG(ByVal pict As StdPicture, ByVal fileName As String, Optional ByVal quality As Byte = 80) As Boolean
Dim tSI As GdiplusStartupInput
Dim lRes As Long
Dim lGDIP As Long
Dim lBitmap As Long
'初始化 GDI+
tSI.GdiplusVersion = 1
lRes = GdiplusStartup(lGDIP, tSI, 0)
If lRes = 0 Then
'从句柄创建 GDI+ 图像
lRes = GdipCreateBitmapFromHBITMAP(pict.Handle, 0, lBitmap)
If lRes = 0 Then
Dim tJpgEncoder As GUID
Dim tParams As EncoderParameters
'初始化解码器的GUID标识
CLSIDFromString StrPtr("{557CF401-1A04-11D3-9A73-0000F81EF32E}"), tJpgEncoder
'设置解码器参数
tParams.Count = 1
With tParams.Parameter ' Quality
'得到Quality参数的GUID标识
CLSIDFromString StrPtr("{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}"), .GUID
.NumberOfValues = 1
.type = 4
.Value = VarPtr(quality)
End With
'保存图像
lRes = GdipSaveImageToFile(lBitmap, StrPtr(fileName), tJpgEncoder, tParams)
'销毁GDI+图像
GdipDisposeImage lBitmap
End If
'销毁 GDI+
GdiplusShutdown lGDIP
End If
If lRes Then
PictureBoxSaveJPG = False
Else
PictureBoxSaveJPG = True
End If
End Function
d.使用以下代码实现将加好文字水印图片保存为jpg格式图片。
Private Sub Command3_Click() '保存为.jpg图片
' 设置“CancelError”为 True
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' 设置标志
CommonDialog1.Flags = cdlOFNHideReadOnly
' 设置过滤器
CommonDialog1.Filter = "JPEG Files" "(*.jpg)|*.jpg"
' 指定缺省的过滤器
CommonDialog1.FilterIndex = 2
' 显示“打开”对话框
CommonDialog1.ShowSave
' 显示选定文件的名字
'MsgBox CommonDialog1.fileName
Set Picture2.Picture = Picture1.Image '转移Picture1所绘图为Picture2.Picture赋值
Dim ret As Boolean
ret = PictureBoxSaveJPG(Picture2, CommonDialog1.fileName) '保存压缩后的图片
If ret = False Then
MsgBox "保存失败"
End If
Exit Sub
ErrHandler:
' 用户按了“取消”按钮
Exit Sub
End Sub
VB2010或VB.NET 怎么能将自身窗体的所有内容保存为图片
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
System.Windows.Forms.SendKeys.Send("%{PRTSC}")
Delay(0.1)
Dim bmp As Bitmap = CType(Clipboard.GetDataObject().GetData(DataFormats.Bitmap), Bitmap)
bmp.Save("c:\test1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
Private Sub Delay(ByVal tim As Single)
Dim t As Single = Microsoft.VisualBasic.Timer + tim
While t Microsoft.VisualBasic.Timer
My.Application.DoEvents()
End While
End Sub
文章标题:vb.net窗体保存图片 vb窗体保存的文件
新闻来源:http://pwwzsj.com/article/dogeigc.html