首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >屏幕录制gif软件_手机录屏咋录内部声音

屏幕录制gif软件_手机录屏咋录内部声音

作者头像
全栈程序员站长
发布2022-11-05 14:00:36
发布2022-11-05 14:00:36
1.1K00
代码可运行
举报
运行总次数:0
代码可运行

大家好,又见面了,我是你们的朋友全栈君。

效果图如下:

工程源码见文章结尾

通过录制屏幕的区域 可以预览生成的GIF图片 图片比较清晰 源码中可以修改gif质量 源码中可以修改gif帧数 通过鼠标选择需要的区域

代码语言:javascript
代码运行次数:0
运行
复制
            FrmRect frmRect = new FrmRect();
            frmRect.ShowDialog();
            m_rect = frmRect.Rect;
            label4.Text = "区域设定完成";
代码语言:javascript
代码运行次数:0
运行
复制
   protected override void OnLoad(EventArgs e) {
            Rectangle rect = Win32.GetDesktopRect();
            this.Location = rect.Location;
            this.Size = rect.Size;

            m_img = this.GetScreen();
            m_imgDark = new Bitmap(this.Width,this.Height);
            using (SolidBrush sb = new SolidBrush(Color.FromArgb(127, 0, 0, 0))) {

.......
}
代码语言:javascript
代码运行次数:0
运行
复制
  private Image GetScreen() {
            Bitmap bmp = new Bitmap(this.Width, this.Height);
            using (Graphics g = Graphics.FromImage(bmp)) {
                g.CopyFromScreen(0, 0, 0, 0, bmp.Size);
代码语言:javascript
代码运行次数:0
运行
复制
  if (btn_start.Text == "开始录制")
            {
                if (m_scrRecorder != null) m_scrRecorder.Clear();
                m_scrRecorder = null;

                if (m_scrRecorder == null)
                {
                    if (m_rect != Rectangle.Empty)
                    {
                        m_scrRecorder = new ScreenRecorder(m_rect, 100);
                        

                    }
                    else
                    {
                        MessageBox.Show("确保对应的录制方式 有选择数据");
                        return;
                    }
                }
                m_scrRecorder.DrawCursor = chk_drawMouse.Checked;
                m_scrRecorder.Start();
                btn_start.Text = "停止";
                btn_preview.Enabled = false;
                label4.Text = "正在录制";

            }
            else
            {
                m_scrRecorder.Stop();
                btn_start.Text = "开始录制";
                 btn_preview.Enabled = true;
                label4.Text = "录制完成";

            }
        }
代码语言:javascript
代码运行次数:0
运行
复制
 private string GetImageHash(Image img)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] byImg = new byte[ms.Length];
                ms.Seek(0, SeekOrigin.Begin);
                ms.Read(byImg, 0, byImg.Length);
                return BitConverter.ToString(System.Security.Cryptography.MD5.Create().ComputeHash(byImg)).Replace("-", "");
            }
        }
    }
代码语言:javascript
代码运行次数:0
运行
复制
       private bool m_bGet;
        private GIFColorDepth m_cd;
        private List<byte> m_lst = new List<byte>();


        private int m_nIndexTrans;                        // transparent index in color table
        private int m_nRepeat = 0;                        // 0=repeat forever

        private byte[] m_nIndexedPixels;                  // converted frame indexed to palette
        private byte[] m_byColorTabs;                     // RGB palette
        private bool[] m_bUsedEntrys = new bool[256];     // active palette entries
        private int m_nPalSize = 7;                       // color table size (bits-1)
        private int n_nDispose = -1;                      // disposal code (-1 = use default)
        private bool m_bFirstFrame = true;

        public GIFCreator(int nWidth, int nHeight, GIFColorDepth cd) {
            this._Width = nWidth;
            this._Height = nHeight;
            m_cd = cd;
            m_lst.AddRange(Encoding.ASCII.GetBytes("GIF89a"));
            this.WriteLSD();    // logical screen descriptior
        }

        public void AddFrame(Image img, int nSleep) {
            if (m_bGet) {       //如果获取过图像数据 那么把末尾的结束标志去掉
                m_lst.RemoveAt(m_lst.Count - 1);
                m_bGet = false;
            }
            this.AnalyzePixels(this.GetImagePixels(img));   // build color table & map pixels
            if (m_bFirstFrame) {
                this.WritePalette();                        // global color table
                if (m_nRepeat >= 0) {
                    this.WriteNetscapeExt();                // use NS app extension to indicate reps
                }
            }
            this.WriteGraphicCtrlExt(nSleep);               // write graphic control extension
            this.WriteImageDesc();                          // image descriptor
            if (!m_bFirstFrame) {
                this.WritePalette();                        // local color table
            }
            this.WritePixels();                             // encode and write pixel data
            m_bFirstFrame = false;
        }

项目链接

GIF录屏制作工具_录制屏幕生成GIF-C#文档类资源-CSDN下载

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/191571.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年9月20日 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档