成都创新互联网站制作重庆分公司

vb.net图片拷贝 vb导入图片的代码

vb.net中怎么将chart中的图表复制到剪贴板和另存为成图片文件?求大神帮助

private void Save_Click(object sender, System.EventArgs e) { // Create a new save file dialog SaveFileDialog saveFileDialog1 = new SaveFileDialog(); // Sets the current file name filter string, which determines // the choices that appear in the "Save as file type" or // "Files of type" box in the dialog box. saveFileDialog1.Filter = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|SVG (*.svg)|*.svg|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif"; saveFileDialog1.FilterIndex = 2 ; saveFileDialog1.RestoreDirectory = true ; // Set image file format if(saveFileDialog1.ShowDialog() == DialogResult.OK) { ChartImageFormat format = ChartImageFormat.Bmp; if( saveFileDialog1.FileName.EndsWith( "bmp" ) ) { format = ChartImageFormat.Bmp; } else if( saveFileDialog1.FileName.EndsWith( "jpg" ) ) { format = ChartImageFormat.Jpeg; } else if( saveFileDialog1.FileName.EndsWith( "emf" ) ) { format = ChartImageFormat.Emf; } else if( saveFileDialog1.FileName.EndsWith( "gif" ) ) { format = ChartImageFormat.Gif; } else if( saveFileDialog1.FileName.EndsWith( "png" ) ) { format = ChartImageFormat.Png; } else if( saveFileDialog1.FileName.EndsWith( "tif" ) ) { format = ChartImageFormat.Tiff; } else if( saveFileDialog1.FileName.EndsWith( "svg" ) ) { format = ChartImageFormat.Svg; } // Save image Chart1.SaveImage( saveFileDialog1.FileName, format ); } }

成都创新互联从2013年开始,先为宜章等服务建站,宜章等地企业,进行企业商务咨询服务。为宜章企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

vb.net如何取得excel中的图片

Dim ss As Excel.Worksheet

Dim i As Integer

Dim b As Bitmap

Dim iData As IDataObject

'excel.Version

ss = wb.Worksheets(2)

For i = 1 To ss.Shapes.Count

ss.Shapes.Item(i).CopyPicture(, excel.XlCopyPictureFormat.xlPicture)

iData = Clipboard.GetDataObject()

If iData.GetDataPresent(DataFormats.Bitmap) Then

b = CType(iData.GetData(DataFormats.Bitmap), Bitmap)

b.Save("d:\sv" + CStr(i) + ".png")

End If

Next i

怎么让VB.NET 上传图片到SQL 数据库只保存路径,图片保存到文件

一个参考过程,你试试 这里写下一个过程为: insert into pub_infor values('1234',0x,'this is a sample') 然后读入图片: sp_textcopy @srvname = '.', @login = 'sa', @password = 'sa', @dbname = 'pubs', @tbname = 'pub_info', @colname = 'logo', @filename = 'c:\picture.bmp', @whereclause = " WHERE pub_id='1234' ", @direction = 'I' 读出为: sp_textcopy @srvname = '.', @login = 'sa', @password = 'sa', @dbname = 'pubs', @tbname = 'pub_info', @colname = 'logo', @filename = 'D:\picture.bmp', @whereclause = " WHERE pub_id='1234' ", @direction = 'O' 清空:update 表 set 列=null 最后注意事项:因为filename的字符长度只有30个:即: @filename varchar (30), 所以实际应用的时候最好改为255个,当含有比较长的路径的时候就会报错: ERROR: Augment 'xxx' unrecognize 还有参数的长度@exec_str varchar (255)也修改下比较好: 我改成了这样子: CREATE PROCEDURE sp_textcopy ( @srvname varchar (30), @login varchar (30), @password varchar (30), @dbname varchar (30), @tbname varchar (30), @colname varchar (30), @filename varchar (255), @whereclause varchar (40), @direction char(1)) AS DECLARE @exec_str varchar (400) SELECT @exec_str = 'textcopy /S ' + @srvname + ' /U ' + @login + ' /P ' + @password + ' /D ' + @dbname + ' /T ' + @tbname + ' /C ' + @colname + ' /W "' + @whereclause + '" /F ' + @filename + ' /' + @direction EXEC master..xp_cmdshell @exec_str 就只这样子了,感觉上T_SQL编程还是挺强大的,有时间应该好好学习下。 回答: 这里以SQL_server2000中的pubs数据库中的pub_info表为例来说说其中的过程:pub_info表包含:pub_id,logo,pr_info,其中logo属于image超长字段,应用存储过程奖图像存储在数据库的步骤包括: 1:首先:是插入一个列: 比如:insert into pub_infor values('1234',0x,'this is a sample')其中0x只是为了确保image字段不能为空:因为下面的存储过程:textcopy 用textcopy把图片或者文件拷贝到image类型字段之前,image类型的字段不能为空。先插入0x(或者0x0)到这个字段,然后就可以用textcopy了。 否则就会报这样的错误: ERROR: Text or image pointer and timestamp retrieval failed. 2:接下来建立存储过程: CREATE PROCEDURE sp_textcopy ( @srvname varchar (30), @login varchar (30), @password varchar (30), @dbname varchar (30), @tbname varchar (30), @colname varchar (30), @filename varchar (30), @whereclause varchar (40), @direction char(1)) AS DECLARE @exec_str varchar (255) SELECT @exec_str = 'textcopy /S ' + @srvname + ' /U ' + @login + ' /P ' + @password + ' /D ' + @dbname + ' /T ' + @tbname + ' /C ' + @colname + ' /W "' + @whereclause + '" /F ' + @filename + ' /' + @direction EXEC master..xp_cmdshell @exec_str 说明: 其中xp_cmdshell: 以操作系统命令行解释器的方式执行给定的命令字符串,并以文本行方式返回任何输出。授予非管理用户执行 xp_cmdshell 的权限。我自己的理解是: textcopy就像是一个dos命令:就是说实际的文件copy命令是类似操作系统执行的。

采纳哦

如何把VB.NET内部资源文件复制到磁盘上

可以查看附件,或则使用以下代码。应该注释的满全了。

随便建一个窗口工程,窗口代码帖入以下代码。

Imports System.IO

Imports System.Text

Imports System.Reflection

Public Class Form1

Const ResName As String = "123.txt" ' 需要保存的资源名

Const BufferSize As Integer = 4096  ' 复制时缓冲的大小

Private Sub Demo()

' 变量声明

Dim strDisplayText As StringBuilder ' 保存输出信息

Dim strResName As String            ' 保存目标资源的名称

' 变量初始化

strDisplayText = New StringBuilder()

strResName = String.Empty

' 获取所有资源

strDisplayText.AppendLine("文件中存在以下资源:")

For Each strName As String In Assembly.GetExecutingAssembly.GetManifestResourceNames()

strDisplayText.AppendLine("  "  strName)

' 获得目标资源的全名

If strName.EndsWith("."  ResName) Then

strResName = strName

End If

Next

' 目标资源不存在

strDisplayText.AppendLine()

If strResName = String.Empty Then

strDisplayText.AppendLine("抱歉,没有找名为"""  ResName  """的资源")

Else ' 复制资源的代码

' 打开资源文件,在End Using的时候自动关闭。

Using ms As UnmanagedMemoryStream = Assembly.GetExecutingAssembly.GetManifestResourceStream(strResName)

' 打开磁盘文件,在End Using的时候自动关闭。

Using fs As New FileStream("C:\"  ResName, FileMode.Create)

' 变量声明

Dim Buffer(BufferSize - 1) As Byte  ' 复制文件时的缓冲数组

Dim ReadCount As Integer            ' 此次读取数据的数量

' 还有数据可以读取的情况,一直循环

ReadCount = ms.Read(Buffer, 0, BufferSize)

While ReadCount  0

fs.Write(Buffer, 0, ReadCount) ' 写入到磁盘文件

ReadCount = ms.Read(Buffer, 0, BufferSize)

End While

End Using

End Using

strDisplayText.AppendLine("文件已经复制完毕。")

End If

' 显示消息

MessageBox.Show(strDisplayText.ToString())

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Call Demo()

End

End Sub

End Class


分享标题:vb.net图片拷贝 vb导入图片的代码
浏览地址:http://cxhlcq.com/article/hjcghs.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部