【RTF文本框】在 RichTextBox 中自动加载笑脸

查看数: 490 | 评论数: 1 | 收藏 0
提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2022-12-25 11:58

正文摘要:

说明: 在 RichTextBox 中自动加载笑脸 在您键入时自动在 RichTextBox 中加载笑脸的简单 WinForm 应用程序我还在下面附上了 .zip 源代码 效果截图:

回复

qiaoke_song 发表于 2022-12-25 19:30:41
本帖最后由 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);

QQ|申请友链|小黑屋|手机版|Archiver|CSkin ( 粤ICP备13070794号

Powered by Discuz! X3.2  © 2001-2013 Comsenz Inc.  Designed by ARTERY.cn
GMT+8, 2024-5-7 11:34, Processed in 0.549045 second(s), 34 queries , Gzip On.

快速回复 返回顶部 返回列表