zoukankan      html  css  js  c++  java
  • C#线程的实现

    原创:
    private
     void button1_Click(object sender, System.EventArgs e)
            {
                button1.Enabled
    =false;
                ThreadStart threadDelegate 
    = new ThreadStart(execute);
                Thread thread 
    = new Thread(threadDelegate);
                thread.Start();
            }
    private void execute()
            {
                Bitmap newbmp
    =new Bitmap(textBox1.Text);
                pictureBox1.Image
    =newbmp;
                Bitmap bmp
    =(Bitmap)pictureBox1.Image;
                
    string tmp="";
                
    string tmp2="";
                
    int a=0;
                
    int b=0;
                
    try 
                {
                    
    for(int j=0;j<pictureBox1.Image.Height;j=j+8)
                    {
                        tmp2
    ="";
                        
    for(int i=0;i<pictureBox1.Image.Width;i=i+8)
                        {
                        
                            Color pixelColor
    =bmp.GetPixel(i,j);
                            tmp
    ="("+pixelColor.R.ToString()+","+pixelColor.G.ToString()+","+pixelColor.B.ToString()+")";
                            
    if(tmp=="(255,255,255)")
                                tmp2
    =tmp2+"0,";                    
                            
    else
                                tmp2
    =tmp2+"1,";    
                            a
    =a+1;
                        }
                        tmp2
    =tmp2.Substring(0,tmp2.Length-1);
                        WriteFile(
    "test.txt","MapArr["+ b +"] = new Array("+tmp2+");");
                        
    this.Text=""+b.ToString()+"行写入成功";
                        b
    =b+1;
                    }
                    
    this.Text="生成成功!";
                    button1.Enabled 
    = true;
                }
                
    catch 
                {
                    
    this.Text="图片格式不支持或写入文件发生异常!";
                }
            }
  • 相关阅读:
    Legacy(点对线段有路走,线段向点有路走,线段树走dij)
    G. Death DBMS(查询每个主串和n个模板串匹配后val最大值,支持单点更新)
    2020 CCPC Wannafly Winter Camp Day5 J Xor on Figures(矩阵转01串,统计01串异或种类)
    zoj3988(自己集合和自己集合匹配)
    2020 CCPC Wannafly Winter Camp Day7 A(求任何子序列中相邻范围内数的个数的总和)
    hdu6241(给定树中向上向下限制求最小可能个数)
    hdu6230(求限制条件的回文个数,利用manacher+BIT求解)
    NOIP 2020 游记
    分散层叠算法学习笔记
    代理模式
  • 原文地址:https://www.cnblogs.com/chinatefl/p/400555.html
Copyright © 2011-2022 走看看