首页 > 编程语言 >直播平台搭建源码,更改图片透明度

直播平台搭建源码,更改图片透明度

时间:2023-01-06 14:23:38浏览次数:40  
标签:更改 Image System trackBar1 button1 直播 pictureBox1 new 源码

直播平台搭建源码,更改图片透明度

 

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    Image new_img;
    private void ChangeAlpha()
    {
        pictureBox1.Refresh();
        Bitmap source = new Bitmap(pictureBox1.Image);
        Bitmap effect = new Bitmap(pictureBox1.Image.Width,pictureBox1.Image.Height);
        Graphics _effect = Graphics.FromImage(effect);
        float[][] matrixItems ={new float[]{1,0,0,0,0},
                                  new float [] {0,1,0,0,0},
                                  new float []{0,0,1,0,0},
                                  new float []{0,0,0,0,0},
                                  new float[]{0,0,0,trackBar1.Value/255f,1}};
        ColorMatrix imgMatrix = new ColorMatrix(matrixItems);
        ImageAttributes imgEffect = new ImageAttributes();
        imgEffect.SetColorMatrix(imgMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
        if (source.Width <= 368)
        {
            _effect.DrawImage(source, new Rectangle(0, 0, pictureBox1.Image.Width, pictureBox1.Image.Height), 0, 0, pictureBox1.Image.Width, pictureBox1.Image.Height, GraphicsUnit.Pixel, imgEffect);
        }
        else
        {
            _effect.DrawImage(pictureBox1.Image, new Rectangle(0, 0, pictureBox1.Image.Width, pictureBox1.Image.Height), 0, 0, pictureBox1.Image.Width, pictureBox1.Image.Height, GraphicsUnit.Pixel, imgEffect);
        }
        pictureBox1.Image = effect;
    }
    private void Form1_Load(object sender, EventArgs e)
    {
    }
    private void trackBar1_ValueChanged(object sender, EventArgs e)
    {
        ChangeAlpha();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
        }
    }
}
partial class Form1
{
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;
    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }
    #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
        this.pictureBox1 = new System.Windows.Forms.PictureBox();
        this.trackBar1 = new System.Windows.Forms.TrackBar();
        this.button1 = new System.Windows.Forms.Button();
        this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
        this.SuspendLayout();
        // 
        // pictureBox1
        // 
        this.pictureBox1.Location = new System.Drawing.Point(12, 80);
        this.pictureBox1.Name = "pictureBox1";
        this.pictureBox1.Size = new System.Drawing.Size(424, 258);
        this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
        this.pictureBox1.TabIndex = 0;
        this.pictureBox1.TabStop = false;
        // 
        // trackBar1
        // 
        this.trackBar1.Location = new System.Drawing.Point(12, 41);
        this.trackBar1.Maximum = 100;
        this.trackBar1.Minimum = 1;
        this.trackBar1.Name = "trackBar1";
        this.trackBar1.Size = new System.Drawing.Size(424, 45);
        this.trackBar1.TabIndex = 1;
        this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
        this.trackBar1.Value = 100;
        this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(12, 12);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 23);
        this.button1.TabIndex = 2;
        this.button1.Text = "打开图片";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // openFileDialog1
        // 
        this.openFileDialog1.Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(447, 350);
        this.Controls.Add(this.pictureBox1);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.trackBar1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
        this.ResumeLayout(false);
        this.PerformLayout();
    }
    #endregion
    private System.Windows.Forms.PictureBox pictureBox1;
    private System.Windows.Forms.TrackBar trackBar1;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.OpenFileDialog openFileDialog1;
}

以上就是 直播平台搭建源码,更改图片透明度,更多内容欢迎关注之后的文章

 

标签:更改,Image,System,trackBar1,button1,直播,pictureBox1,new,源码
From: https://www.cnblogs.com/yunbaomengnan/p/17030338.html

相关文章

  • MongoDB源码包安装
    文章目录​​1.download​​​​1.1版本说明​​​​2.解压​​​​3.准备配置文件​​​​4.启动​​​​5.安装过程中的问题​​1.download​​https://www.mongod......
  • 如何做好美颜sdk与直播平台的适配?
    美颜sdk作为目前社交视频拍摄平台用户的刚需,在近几年可谓是名声大噪,无论是强大的美颜功能还是多元化的趣味拍摄方案都让用户们“爱不释手”,平台自然也是看中了这一点,纷纷为......
  • Java并发容器之LinkedBlockingQueue源码分析
    一、简介LinkedBlockingQueue是java并发包下一个以单链表实现的阻塞队列,它是线程安全的,至于它是不是有界的,请看下面的分析。二、源码分析2.1属性 //容量private......
  • (四)elasticsearch 源码之索引流程分析
    1.概览前面我们讨论了es是如何启动,本文研究下es是如何索引文档的。下面是启动流程图,我们按照流程图的顺序依次描述。  其中主要类的关系如下:  2.索引流程......
  • [源码]JS加密:调用JShaman接口,实现JS代码加密
    源码如下,保存为html即可直接使用。免费版:<html><head><scriptsrc="https://code.jquery.com/jquery-1.11.3.js"></script></head><bo......
  • 直播回顾 | 这场直播回答了手机银行人机验证的必要性和可行性
    人机验证作为手机银行验证体系中重要的一环,其验证码的安全性以及用户体验成为了主要考验。12月22日,顶象资深解决方案专家鳯羽就手机银行的人机验证解决方案讲起,从人机验......
  • 钉钉直播回放下载
    准备工具N_m3u8DL-CLI抓包工具下载并安装配置抓包工具:选择Tools->Options,ations选择Trustrootcertifiect,过程中的弹窗全部选择yesvarsToInsert="<s......
  • 解决ensp中usg每次启动都需要更改密码的问题
    想办法创建一个后缀为.cfg的文件,内容如下aaamanager-useradminpasswordcipherxxxxxxxx//这里为登录的密码;需要注意的是要符合usg的密码规则,不然会失败,即要含有大小写s......
  • 为什么巨头的 Flink 作业运行都在 YARN 上?(附源码)
    曾有人调侃:HBase没有资源什么事情也做不了,Spark占用了资源却没有事情可做? 那YARN了解一下?01YARN!伴随着Hadoop生态的发展,不断涌现了多种多样的技术组件Hive、HBase、Spa......
  • canvas 源码汇总
    Source/core/html/canvasContainscanvas-relatedsupportclasses,including:thebaseclassforallCanvasRenderingContextthebaseclassforallelementsthat......