本帖最后由 qiaoke_song 于 2022-12-25 19:35 编辑 RichTextBox这个东西么,主要是写入了图像要读取出来用的。解决的深入一点,参考下。注意下.net4.5以下 winform的,可以优化修改 链接:https://pan.baidu.com/s/1CtVLACvGVQQIktv3TWovhg 提取码:hk0z wpf的 http://bbs.cskin.net/thread-15573-1-1.html winform的麻烦一些,要找结构写入才能读取, byte[] _FileBytes = File.ReadAllBytes(p_FileFullPath); Image _Image = Image.FromStream(new MemoryStream(_FileBytes)); string _Guid = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", ""); StringBuilder _RtfText = new StringBuilder(@"{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fcharset134 \'cb\'ce\'cc\'e5;}}\uc1\pard\lang2052\f0\fs18{\object\objemb{\*\objclass Paint.Picture}"); _RtfText.Append(@"\objw" + _Width.ToString() + @"\objh" + _Height.ToString()); _RtfText.AppendLine(@"{\*\objdata"); _RtfText.AppendLine(@"010500000200000007000000504272757368000000000000000000" + BitConverter.ToString(BitConverter.GetBytes(_FileBytes.Length + 20)).Replace("-", "")); _RtfText.Append("7A676B65" + _Guid); _RtfText.AppendLine(BitConverter.ToString(_FileBytes).Replace("-", "")); _RtfText.AppendLine(@"0105000000000000}{\result{\pict\wmetafile0}}}}"); base.SelectedRtf = _RtfText.ToString(); wpf的简单多了 Image image = new Image() { Width = imagesize, Height = imagesize, UseLayoutRounding = true, Source = new BitmapImage(new Uri(imageUrl, UriKind.RelativeOrAbsolute)) }; new InlineUIContainer(image, rtb.Selection.Start); |