大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
效果图如下:
工程源码见文章结尾
通过录制屏幕的区域 可以预览生成的GIF图片 图片比较清晰 源码中可以修改gif质量 源码中可以修改gif帧数 通过鼠标选择需要的区域
FrmRect frmRect = new FrmRect();
frmRect.ShowDialog();
m_rect = frmRect.Rect;
label4.Text = "区域设定完成";
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))) {
.......
}
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);
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 = "录制完成";
}
}
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("-", "");
}
}
}
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下载
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/191571.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...