private buffersize As integer保存:
Try
With OpenFileDialog
.Filter = "图片文件(*.jpg)|*.jpg|所有文件(*.*)|*.*"
If .ShowDialog() = DialogResult.OK Then
txtLocation.Text = OpenFileDialog.FileName Dim objFileStream As New FileStream(txtLocation.Text, IO.FileMode.Open)
objFileStream.Position = 0
Dim tmpImage() As Byte
ReDim tmpImage(objFileStream.Length - 1)
objFileStream.Read(tmpImage, 0, objFileStream.Length)
buffersize = objFileStream.Length
picPhoto.Image = Image.FromStream(objFileStream) Dim xw As New Xml.XmlTextWriter("c:\TempXmlX.xml", Encoding.UTF8)
xw.WriteStartDocument()
xw.WriteStartElement("root")
xw.WriteBase64(tmpImage, 0, tmpImage.Length)
objFileStream.Close()
xw.WriteEndElement()
xw.WriteEndDocument()
xw.Flush()
xw.Close() End If
End With Catch ex As Exception
MsgBox("选择文件出错!出错原因如下:" & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "提示")
txtLocation.Text = ""
txtPhoto.Text = ""
End Try显示:
Try
Dim buffer(buffersize) As Byte
Dim xr As New Xml.XmlTextReader("c:\TempXmlY.xml")
xr.MoveToContent()
xr.ReadBase64(buffer, 0, buffersize)
xr.Close() Dim objMemStream As New MemoryStream
objMemStream.Write(buffer, 0, buffersize)
objMemStream.Position = 0
picPhoto.Image = Image.FromStream(objMemStream)
Invalidate()
objMemStream.Close()
Catch ex As Exception
MsgBox("图形显示出错!出错原因如下:" & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "提示")
End Try
Try
With OpenFileDialog
.Filter = "图片文件(*.jpg)|*.jpg|所有文件(*.*)|*.*"
If .ShowDialog() = DialogResult.OK Then
txtLocation.Text = OpenFileDialog.FileName Dim objFileStream As New FileStream(txtLocation.Text, IO.FileMode.Open)
objFileStream.Position = 0
Dim tmpImage() As Byte
ReDim tmpImage(objFileStream.Length - 1)
objFileStream.Read(tmpImage, 0, objFileStream.Length)
buffersize = objFileStream.Length
picPhoto.Image = Image.FromStream(objFileStream) Dim xw As New Xml.XmlTextWriter("c:\TempXmlX.xml", Encoding.UTF8)
xw.WriteStartDocument()
xw.WriteStartElement("root")
xw.WriteBase64(tmpImage, 0, tmpImage.Length)
objFileStream.Close()
xw.WriteEndElement()
xw.WriteEndDocument()
xw.Flush()
xw.Close() End If
End With Catch ex As Exception
MsgBox("选择文件出错!出错原因如下:" & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "提示")
txtLocation.Text = ""
txtPhoto.Text = ""
End Try显示:
Try
Dim buffer(buffersize) As Byte
Dim xr As New Xml.XmlTextReader("c:\TempXmlY.xml")
xr.MoveToContent()
xr.ReadBase64(buffer, 0, buffersize)
xr.Close() Dim objMemStream As New MemoryStream
objMemStream.Write(buffer, 0, buffersize)
objMemStream.Position = 0
picPhoto.Image = Image.FromStream(objMemStream)
Invalidate()
objMemStream.Close()
Catch ex As Exception
MsgBox("图形显示出错!出错原因如下:" & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "提示")
End Try
解决方案 »
- wmf类型图片在水晶报表中显示不清晰
- 求高手帮忙解决:如何DataList的字段值??老提示System.EventArgs并不包含"Item"的定义,代码如下
- 在从服务器接收结果时发生传输级错误。 (provider: TCP Provider, error: 0 - 句柄无效。)
- Dim clsB As New sqlDLTP.business 需要加入什么控件,在VS2005 VB.NET语言.未定义类型“sqlDLTP.business”。
- 关于JS控制层的显示.刷新后仍然保持刷新前层的显示
- 请问如何给加密的ACCESS数据库建立数据源啊 ?急。。。。。
- 熬了将近一个月,搞出来的东西大大家一起分享
- 没分了,问一下CrystalReportViewer怎么重装~
- 用DataList绑定时间时怎么设置时间格式
- RadioButton模板列问题!!!
- 讨论怎么让oracle的对话结束的快一点?
- 怎样将数据库数据绑定到TEXTBOX控件呀?在线急等!!!
string strXmlFile = "c:\\222.xml";FileStream fs = new FileStream(strImgFile, FileMode.Open, FileAccess.Read);
byte[] bytes = new Byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
XmlTextWriter tw = new XmlTextWriter(strXmlFile, System.Text.Encoding.UTF8);
tw.WriteStartDocument();
tw.WriteStartElement("root");
tw.WriteBase64(bytes, 0, bytes.Length);
tw.WriteEndElement();
tw.WriteEndDocument();
tw.Flush();
tw.Close();