如何读取RichTextbox 中的图片到一个byte()

jxzhang615 2009-08-01 11:00:07
RT
先谢谢大家关注,分不是问题!!
...全文
198 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
CloneCenter 2009-08-02
  • 打赏
  • 举报
回复
6 楼的代码没有用的,楼主要的是从 RichtextBox 中获取图片。
kuhura 2009-08-02
  • 打赏
  • 举报
回复
很麻烦啊,用了些曲折的手段,不知道是不是能得到你想要的,参考如下的代码:

Imports System.Runtime.Serialization.Formatters.Binary
Imports System.IO

Public Class Test

Dim YourImage As Image = "你的图片"
Dim FileName As String = "文件名"

Public Sub ImageToFile()
Dim fs As New FileStream(FileName, FileMode.Create)
Dim BF_Image As New BinaryFormatter
Try
BF_Image.Serialize(fs, YourImage)
Dim B() As Byte
ReDim B(fs.Length)
fs.Read(B, 0, fs.Length)

Console.WriteLine(B.Length)
'此处B为得到的二进制数组,可能会非常大
Catch e As Exception
Console.WriteLine(e.Message)
Finally
fs.Close()
End Try

End Sub

Public Sub FileToImage()
Dim fs As New FileStream(FileName, FileMode.Open)
Try
Dim BF_Image As New BinaryFormatter
YourImage = DirectCast(BF_Image.Deserialize(fs), System.Drawing.Image)
Catch e As Exception
Console.WriteLine(e.Message)
Finally
fs.Close()
End Try
End Sub

end Test
jxzhang615 2009-08-01
  • 打赏
  • 举报
回复
自己再顶一下!
谢谢大家关注
蒋晟 2009-08-01
  • 打赏
  • 举报
回复
先得找到图片的ReObject
不知道怎么从.Net的封装找,直接调用Windows API的话是IRichEditOle::GetObject
古今多少事 2009-08-01
  • 打赏
  • 举报
回复
保存是:Dim ArrPic() As Byte = CType(YourImage,Byte()) ,如何读取就不知道了……
lghndyz 2009-08-01
  • 打赏
  • 举报
回复
帮顶一下!!
bw555 2009-08-01
  • 打赏
  • 举报
回复

ctype(myimage,byte())

16,721

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧