C# IMEI15位转换成8位密码

UI展示:

ExcelHelper.cs:


using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IMEIConvertPwdTools.V1._00
{
    public static class ExcelHelper
    {
        /// <summary>
        /// Excel导入成DataTable
        /// </summary>
        /// <param name="file">导入路径(包含文件名与扩展名)</param>
        /// <returns></returns>
        public static DataTable ExcelToTable(string file)
        {
            if (file == "") return null;

            DataTable dt = new DataTable();
            IWorkbook workbook;//工作簿接口
            string fileExt = Path.GetExtension(file).ToLower();
            using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
            {
                //XSSFWorkbook 适用XLSX格式,HSSFWorkbook 适用XLS格式
                if (fileExt == ".xlsx")//新版本excel2007
                {
                    workbook = new XSSFWorkbook(fs);
                }
                else if (fileExt == ".xls")//早期版本excel2003
                {
                    workbook = new HSSFWorkbook(fs);
                }
                else
                {
                    workbook = null;
                }
                if (workbook == null) { return null; }

                ISheet sheet = workbook.GetSheetAt(0);//下标为零的工作簿

                //创建表头      FirstRowNum:获取第一个有数据的行好(默认0)
                IRow header = sheet.GetRow(sheet.FirstRowNum);//第一行是头部信息
                List<int> columns = new List<int>();
                for (int i = 0; i < header.LastCellNum; i++)//LastCellNum 获取列的条数
                {
                    object obj = GetValueType(header.GetCell(i));
                    if (obj == null || obj.ToString() == string.Empty)
                    {
                        dt.Columns.Add(new DataColumn("Columns" + i.ToString()));//如果excel没有列头就自定义
                    }
                    else
                        dt.Columns.Add(new DataColumn(obj.ToString()));//获取excel列头
                    columns.Add(i);
                }


                //构建数据   sheet.FirstRowNum + 1 表示去掉列头信息
                for (int i = sheet.FirstRowNum + 1; i <= sheet.LastRowNum; i++)//LastRowNum最后一条数据的行号
                {
                    DataRow dr = dt.NewRow();//编号 名称 价格 描述
                    bool hasValue = false;//判断是否有值
                    foreach (int j in columns)
                    {
                        //if (sheet.GetRow(i) == null) continue;//如果没数据
                        dr[j] = GetValueType(sheet.GetRow(i).GetCell(j));
                        if (dr[j] != null && dr[j].ToString() != string.Empty)//判断至少一列有值
                        {
                            hasValue = true;//不是空的
                        }
                    }
                    if (hasValue)
                    {
                        dt.Rows.Add(dr);
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Datable导出成Excel
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="file">导出路径(包括文件名与扩展名)</param>
        public static void TableToExcel(DataTable dt, string file)
        {
            IWorkbook workbook;
            string fileExt = Path.GetExtension(file).ToLower();
            if (fileExt == ".xlsx")
            { workbook = new XSSFWorkbook(); }
            else if (fileExt == ".xls")
            { workbook = new HSSFWorkbook(); }
            else { workbook = null; }
            if (workbook == null) { return; }
            ISheet sheet = string.IsNullOrEmpty(dt.TableName) ? workbook.CreateSheet("Sheet1") : workbook.CreateSheet(dt.TableName);

            #region 添加一行合并头部并居中显示的列
            //ICellStyle style = workbook.CreateCellStyle();//创建头部列样式
            单独合并头部列
            //IRow h_row = sheet.CreateRow(0);
            //ICell h_cell = h_row.CreateCell(0);
            //h_cell.SetCellValue("测试头部列");//设置单元格细信息
            //h_row.Height = 30 * 20;
            //sheet.SetColumnWidth(0, 30 * 256);//设置单元格的宽度
            //sheet.AddMergedRegion(new CellRangeAddress(0, 0, 0, 10));//合并列
            //style.Alignment = HorizontalAlignment.Center;//居中显示
            新建一个字体样式对象
            //IFont font = workbook.CreateFont();//设置字体加粗样式
            //font.Boldweight = short.MaxValue;//使用SetFont方法将字体样式添加到单元格样式中 
            //style.SetFont(font);//将新的样式赋给单元格
            //h_cell.CellStyle = style;
            #endregion

            //表头  
            IRow row = sheet.CreateRow(0);//去头部修改
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                ICell cell = row.CreateCell(i);
                cell.SetCellValue(dt.Columns[i].ColumnName);
            }

            //数据  
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                IRow row1 = sheet.CreateRow(i + 1);//去头部修改
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    ICell cell = row1.CreateCell(j);
                    cell.SetCellValue(dt.Rows[i][j].ToString());
                }
            }

            //转为字节数组  
            MemoryStream stream = new MemoryStream();//读写内存的对象
            workbook.Write(stream);
            var buf = stream.ToArray();//字节数组
            //保存为Excel文件  
            using (FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write))
            {
                fs.Write(buf, 0, buf.Length);//100.1MB  1MB
                fs.Flush();//缓冲区在内存中有个临时区域  盆 两个水缸 //缓冲区装满才会自动提交
            }
        }

        /// <summary>
        /// 获取单元格类型
        /// </summary>
        /// <param name="cell"></param>
        /// <returns></returns>
        private static object GetValueType(ICell cell)
        {
            if (cell == null)
                return null;
            switch (cell.CellType)
            {
                case CellType.Boolean: //BOOLEAN:  
                    return cell.BooleanCellValue;
                case CellType.Numeric: //NUMERIC:  
                    if (DateUtil.IsCellDateFormatted(cell))//判断是否日期 6位数字
                        return cell.DateCellValue.ToString("yyyy/MM/dd");
                    else
                        return cell.NumericCellValue;
                case CellType.Error: //ERROR:  
                    return cell.ErrorCellValue;
                case CellType.String: //STRING:  
                default:
                    return cell.StringCellValue;

            }
        }

    }
}

 CsvHelper.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IMEIConvertPwdTools.V1._00
{
    public class CSVFileHelper
    {
        /// <summary>
        /// 将DataTable中数据写入到CSV文件中
        /// </summary>
        /// <param name="dt">提供保存数据的DataTable</param>
        /// <param name="fileName">CSV的文件路径</param>
        public static void SaveCSV(DataTable dt, string fullPath)
        {
            FileInfo fi = new FileInfo(fullPath);
            if (!fi.Directory.Exists)
            {
                fi.Directory.Create();
            }
            FileStream fs = new FileStream(fullPath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
            //StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
            StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
            string data = "";
            //写出列名称
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                data += dt.Columns[i].ColumnName.ToString();
                if (i < dt.Columns.Count - 1)
                {
                    data += ",";
                }
            }
            sw.WriteLine(data);
            //写出各行数据
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                data = "";
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    string str = dt.Rows[i][j].ToString();
                    str = str.Replace("\"", "\"\"");//替换英文冒号 英文冒号需要换成两个冒号
                    if (str.Contains(',') || str.Contains('"')
                        || str.Contains('\r') || str.Contains('\n')) //含逗号 冒号 换行符的需要放到引号中
                    {
                        str = string.Format("\"{0}\"", str);
                    }

                    data += str;
                    if (j < dt.Columns.Count - 1)
                    {
                        data += ",";
                    }
                }
                sw.WriteLine(data);
            }
            sw.Close();
            fs.Close();
        }

        /// <summary>
        /// 将CSV文件的数据读取到DataTable中
        /// </summary>
        /// <param name="fileName">CSV文件路径</param>
        /// <returns>返回读取了CSV数据的DataTable</returns>
        public static DataTable OpenCSV(string filePath)
        {
            //Encoding encoding = Common.GetType(filePath); //Encoding.ASCII;//
            DataTable dt = new DataTable();
            FileStream fs = new FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);

            //StreamReader sr = new StreamReader(fs, Encoding.UTF8);
            StreamReader sr = new StreamReader(fs, Encoding.Default);
            //string fileContent = sr.ReadToEnd();
            //encoding = sr.CurrentEncoding;
            //记录每次读取的一行记录
            string strLine = "";
            //记录每行记录中的各字段内容
            string[] aryLine = null;
            string[] tableHead = null;
            //标示列数
            int columnCount = 0;
            //标示是否是读取的第一行
            bool IsFirst = true;
            //逐行读取CSV中的数据
            while ((strLine = sr.ReadLine()) != null)
            {
                //strLine = Common.ConvertStringUTF8(strLine, encoding);
                //strLine = Common.ConvertStringUTF8(strLine);

                if (IsFirst == true)
                {
                    tableHead = strLine.Split(',');
                    IsFirst = false;
                    columnCount = tableHead.Length;
                    //创建列
                    for (int i = 0; i < columnCount; i++)
                    {
                        DataColumn dc = new DataColumn(tableHead[i]);
                        dt.Columns.Add(dc);
                    }
                }
                else
                {
                    aryLine = strLine.Split(',');
                    DataRow dr = dt.NewRow();
                    for (int j = 0; j < columnCount; j++)
                    {
                        dr[j] = aryLine[j];
                    }
                    dt.Rows.Add(dr);
                }
            }
            if (aryLine != null && aryLine.Length > 0)
            {
                dt.DefaultView.Sort = tableHead[0] + " " + "asc";
            }

            sr.Close();
            fs.Close();
            return dt;
        }
    }
}

IMEIConvertPwdEntity.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IMEIConvertPwdTools.V1._00
{
    public class IMEIConvertPwdEntity
    {
        /// <summary>
        /// 序号
        /// </summary>
        public int NO { get; set; }

        /// <summary>
        /// 16位IMEI
        /// </summary>
        public string IMEI{ get; set; }

        /// <summary>
        /// 转换的密码
        /// </summary>
        public string Pwd { get; set; }
    }
}

AutoSizeFormClass.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace IMEIConvertPwdTools.V1._00
{
    public class AutoSizeFormClass
    {
        //(1).声明结构,只记录窗体和其控件的初始位置和大小。  
        public struct controlRect
        {
            public int Left;
            public int Top;
            public int Width;
            public int Height;
        }
        //(2).声明 1个对象  
        //注意这里不能使用控件列表记录 List<Control> nCtrl;,因为控件的关联性,记录的始终是当前的大小。  
        public List<controlRect> oldCtrl;
        //int ctrl_first = 0;  
        //(3). 创建两个函数  
        //(3.1)记录窗体和其控件的初始位置和大小,  
        public AutoSizeFormClass(Form mForm)
        {
            // if (ctrl_first == 0)  
            {
                //  ctrl_first = 1;  
                oldCtrl = new List<controlRect>();
                controlRect cR;
                cR.Left = mForm.Left; cR.Top = mForm.Top; cR.Width = mForm.Width; cR.Height = mForm.Height;
                oldCtrl.Add(cR);
                foreach (Control c in mForm.Controls)
                {
                    controlRect objCtrl;
                    objCtrl.Left = c.Left; objCtrl.Top = c.Top; objCtrl.Width = c.Width; objCtrl.Height = c.Height;
                    oldCtrl.Add(objCtrl);
                }
            }
            // this.WindowState = (System.Windows.Forms.FormWindowState)(2);//记录完控件的初始位置和大小后,再最大化  
            //0 - Normalize , 1 - Minimize,2- Maximize  
        }
        //(3.2)控件自适应大小,  
        public void controlAutoSize(Form mForm)
        {
            //int wLeft0 = oldCtrl[0].Left; ;//窗体最初的位置  
            //int wTop0 = oldCtrl[0].Top;  
            int wLeft1 = this.Left;//窗体当前的位置  
            //int wTop1 = this.Top;  
            float wScale = (float)mForm.Width / (float)oldCtrl[0].Width;//新旧窗体之间的比例,与最早的旧窗体  
            float hScale = (float)mForm.Height / (float)oldCtrl[0].Height;//.Height;  
            int ctrLeft0, ctrTop0, ctrWidth0, ctrHeight0;
            int ctrlNo = 1;//第1个是窗体自身的 Left,Top,Width,Height,所以窗体控件从ctrlNo=1开始  
            foreach (Control c in mForm.Controls)
            {
                ctrLeft0 = oldCtrl[ctrlNo].Left;
                ctrTop0 = oldCtrl[ctrlNo].Top;
                ctrWidth0 = oldCtrl[ctrlNo].Width;
                ctrHeight0 = oldCtrl[ctrlNo].Height;
                //c.Left = (int)((ctrLeft0 - wLeft0) * wScale) + wLeft1;//新旧控件之间的线性比例  
                //c.Top = (int)((ctrTop0 - wTop0) * h) + wTop1;  
                c.Left = (int)((ctrLeft0) * wScale);//新旧控件之间的线性比例。控件位置只相对于窗体,所以不能加 + wLeft1  
                c.Top = (int)((ctrTop0) * hScale);//  
                c.Width = (int)(ctrWidth0 * wScale);//只与最初的大小相关,所以不能与现在的宽度相乘 (int)(c.Width * w);  
                c.Height = (int)(ctrHeight0 * hScale);//  
                ctrlNo += 1;
            }
        }

    }
}

AutoSetControlSize.cs

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace IMEIConvertPwdTools.V1._00
{
    public class AutoSetControlSize
    {
        #region 控件大小随窗体大小等比例缩放
        public float X { get; set; }//定义当前窗体的宽度
        public float Y { get; set; }//定义当前窗体的高度

        /// <summary>
        /// 原始X,Y的座标
        /// </summary>
        /// <param name="form"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>

        public AutoSetControlSize(Form form,float x,float y)
        {
            this.X = x;
            this.Y = y;
            setTag(form);
        }

        private void setTag(Control cons)
        {
            foreach (Control con in cons.Controls)
            {

                con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
                if (con.Controls.Count > 0)
                {
                    setTag(con);
                }
            }
        }
        public void setControls(float newx, float newy, Control cons)
        {

            //遍历窗体中的控件,重新设置控件的值
            foreach (Control con in cons.Controls)
            {
                //获取控件的Tag属性值,并分割后存储字符串数组
                if (con.Tag != null)
                {
                    string[] mytag = con.Tag.ToString().Split(new char[] { ';' });
                    //根据窗体缩放的比例确定控件的值
                    con.Width = Convert.ToInt32(System.Convert.ToSingle(mytag[0]) * newx);//宽度
                    con.Height = Convert.ToInt32(System.Convert.ToSingle(mytag[1]) * newy);//高度
                    con.Left = Convert.ToInt32(System.Convert.ToSingle(mytag[2]) * newx);//左边距
                    con.Top = Convert.ToInt32(System.Convert.ToSingle(mytag[3]) * newy);//顶边距
                    //Single currentSize = System.Convert.ToSingle(mytag[4]) * newy;//字体大小
                    //con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
                    if (con.Controls.Count > 0)
                    {
                        setControls(newx, newy, con);
                    }
                }
            }
        }
        #endregion
    }
}

MainForm.cs


namespace IMEIConvertPwdTools.V1._00
{
    partial class MainForm
    {
        /// <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.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.panel1 = new System.Windows.Forms.Panel();
            this.btn_Close = new System.Windows.Forms.Button();
            this.imageList1 = new System.Windows.Forms.ImageList(this.components);
            this.label5 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
            this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel();
            this.t_SystemDateTime = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripStatusLabel5 = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripStatusLabel6 = new System.Windows.Forms.ToolStripStatusLabel();
            this.t_DataCount = new System.Windows.Forms.ToolStripStatusLabel();
            this.btn_Import = new System.Windows.Forms.Button();
            this.txt_IEMIFilePath = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.dtgrive_ImeiData = new System.Windows.Forms.DataGridView();
            this.NO = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.IMEI_15Bit = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.PassWord_8Bit = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.Men_txt = new System.Windows.Forms.ToolStripMenuItem();
            this.Men_csv = new System.Windows.Forms.ToolStripMenuItem();
            this.Men_xls = new System.Windows.Forms.ToolStripMenuItem();
            this.label2 = new System.Windows.Forms.Label();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            this.panel1.SuspendLayout();
            this.statusStrip1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dtgrive_ImeiData)).BeginInit();
            this.contextMenuStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // splitContainer1
            // 
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
            this.splitContainer1.Name = "splitContainer1";
            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // splitContainer1.Panel1
            // 
            this.splitContainer1.Panel1.Controls.Add(this.panel1);
            // 
            // splitContainer1.Panel2
            // 
            this.splitContainer1.Panel2.Controls.Add(this.statusStrip1);
            this.splitContainer1.Panel2.Controls.Add(this.btn_Import);
            this.splitContainer1.Panel2.Controls.Add(this.txt_IEMIFilePath);
            this.splitContainer1.Panel2.Controls.Add(this.label4);
            this.splitContainer1.Panel2.Controls.Add(this.label3);
            this.splitContainer1.Panel2.Controls.Add(this.dtgrive_ImeiData);
            this.splitContainer1.Panel2.Controls.Add(this.label2);
            this.splitContainer1.Size = new System.Drawing.Size(1037, 900);
            this.splitContainer1.SplitterDistance = 48;
            this.splitContainer1.SplitterWidth = 1;
            this.splitContainer1.TabIndex = 0;
            // 
            // panel1
            // 
            this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(161)))), ((int)(((byte)(188)))), ((int)(((byte)(219)))));
            this.panel1.Controls.Add(this.btn_Close);
            this.panel1.Controls.Add(this.label5);
            this.panel1.Controls.Add(this.label1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(1037, 48);
            this.panel1.TabIndex = 0;
            this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Frm_MouseDown);
            this.panel1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Frm_MouseMove);
            this.panel1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Frm_MouseUp);
            // 
            // btn_Close
            // 
            this.btn_Close.FlatAppearance.BorderSize = 0;
            this.btn_Close.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.btn_Close.ImageIndex = 1;
            this.btn_Close.ImageList = this.imageList1;
            this.btn_Close.Location = new System.Drawing.Point(990, 11);
            this.btn_Close.Name = "btn_Close";
            this.btn_Close.Size = new System.Drawing.Size(28, 27);
            this.btn_Close.TabIndex = 2;
            this.btn_Close.UseVisualStyleBackColor = true;
            this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click);
            // 
            // imageList1
            // 
            this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
            this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
            this.imageList1.Images.SetKeyName(0, "链接转换工具集.png");
            this.imageList1.Images.SetKeyName(1, "关闭.png");
            this.imageList1.Images.SetKeyName(2, "导入.png");
            this.imageList1.Images.SetKeyName(3, "导入项目_操作_jurassic.png");
            this.imageList1.Images.SetKeyName(4, "数据导入.png");
            // 
            // label5
            // 
            this.label5.ForeColor = System.Drawing.Color.White;
            this.label5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.label5.ImageIndex = 0;
            this.label5.ImageList = this.imageList1;
            this.label5.Location = new System.Drawing.Point(383, 0);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(40, 47);
            this.label5.TabIndex = 0;
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label1
            // 
            this.label1.ForeColor = System.Drawing.Color.White;
            this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.label1.ImageList = this.imageList1;
            this.label1.Location = new System.Drawing.Point(418, 1);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(191, 47);
            this.label1.TabIndex = 0;
            this.label1.Text = "IMEI Convert Pwd Tools";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // statusStrip1
            // 
            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripStatusLabel1,
            this.toolStripStatusLabel2,
            this.toolStripStatusLabel3,
            this.toolStripStatusLabel4,
            this.t_SystemDateTime,
            this.toolStripStatusLabel5,
            this.toolStripStatusLabel6,
            this.t_DataCount});
            this.statusStrip1.Location = new System.Drawing.Point(0, 829);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size(1037, 22);
            this.statusStrip1.TabIndex = 1;
            this.statusStrip1.Text = "statusStrip1";
            // 
            // toolStripStatusLabel1
            // 
            this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
            this.toolStripStatusLabel1.Size = new System.Drawing.Size(110, 17);
            this.toolStripStatusLabel1.Text = "Software Version:";
            // 
            // toolStripStatusLabel2
            // 
            this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
            this.toolStripStatusLabel2.Size = new System.Drawing.Size(40, 17);
            this.toolStripStatusLabel2.Text = "V1.00";
            // 
            // toolStripStatusLabel3
            // 
            this.toolStripStatusLabel3.Name = "toolStripStatusLabel3";
            this.toolStripStatusLabel3.Size = new System.Drawing.Size(296, 17);
            this.toolStripStatusLabel3.Text = "                                                                        ";
            // 
            // toolStripStatusLabel4
            // 
            this.toolStripStatusLabel4.Name = "toolStripStatusLabel4";
            this.toolStripStatusLabel4.Size = new System.Drawing.Size(111, 17);
            this.toolStripStatusLabel4.Text = "System DateTime:";
            // 
            // t_SystemDateTime
            // 
            this.t_SystemDateTime.Name = "t_SystemDateTime";
            this.t_SystemDateTime.Size = new System.Drawing.Size(32, 17);
            this.t_SystemDateTime.Text = "xxxx";
            // 
            // toolStripStatusLabel5
            // 
            this.toolStripStatusLabel5.Name = "toolStripStatusLabel5";
            this.toolStripStatusLabel5.Size = new System.Drawing.Size(208, 17);
            this.toolStripStatusLabel5.Text = "                                                  ";
            // 
            // toolStripStatusLabel6
            // 
            this.toolStripStatusLabel6.Name = "toolStripStatusLabel6";
            this.toolStripStatusLabel6.Size = new System.Drawing.Size(67, 17);
            this.toolStripStatusLabel6.Text = "DataTotal:";
            // 
            // t_DataCount
            // 
            this.t_DataCount.Name = "t_DataCount";
            this.t_DataCount.Size = new System.Drawing.Size(0, 17);
            // 
            // btn_Import
            // 
            this.btn_Import.FlatAppearance.BorderSize = 0;
            this.btn_Import.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.btn_Import.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_Import.ImageIndex = 3;
            this.btn_Import.ImageList = this.imageList1;
            this.btn_Import.Location = new System.Drawing.Point(936, 23);
            this.btn_Import.Name = "btn_Import";
            this.btn_Import.Size = new System.Drawing.Size(82, 33);
            this.btn_Import.TabIndex = 1;
            this.btn_Import.Text = "....";
            this.btn_Import.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btn_Import.UseVisualStyleBackColor = true;
            this.btn_Import.Click += new System.EventHandler(this.btn_Import_Click);
            // 
            // txt_IEMIFilePath
            // 
            this.txt_IEMIFilePath.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txt_IEMIFilePath.Enabled = false;
            this.txt_IEMIFilePath.Location = new System.Drawing.Point(170, 36);
            this.txt_IEMIFilePath.Name = "txt_IEMIFilePath";
            this.txt_IEMIFilePath.ReadOnly = true;
            this.txt_IEMIFilePath.Size = new System.Drawing.Size(760, 19);
            this.txt_IEMIFilePath.TabIndex = 5;
            // 
            // label4
            // 
            this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.label4.Location = new System.Drawing.Point(170, 56);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(760, 1);
            this.label4.TabIndex = 4;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(5, 37);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(168, 16);
            this.label3.TabIndex = 3;
            this.label3.Text = "Load IMEI File Path:";
            // 
            // dtgrive_ImeiData
            // 
            this.dtgrive_ImeiData.AllowUserToAddRows = false;
            this.dtgrive_ImeiData.AllowUserToDeleteRows = false;
            this.dtgrive_ImeiData.BackgroundColor = System.Drawing.Color.White;
            this.dtgrive_ImeiData.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.dtgrive_ImeiData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dtgrive_ImeiData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.NO,
            this.IMEI_15Bit,
            this.PassWord_8Bit});
            this.dtgrive_ImeiData.ContextMenuStrip = this.contextMenuStrip1;
            this.dtgrive_ImeiData.Location = new System.Drawing.Point(33, 92);
            this.dtgrive_ImeiData.Name = "dtgrive_ImeiData";
            this.dtgrive_ImeiData.ReadOnly = true;
            this.dtgrive_ImeiData.RowTemplate.Height = 23;
            this.dtgrive_ImeiData.Size = new System.Drawing.Size(974, 734);
            this.dtgrive_ImeiData.TabIndex = 2;
            this.dtgrive_ImeiData.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.dtgrive_ImeiData_RowsAdded);
            // 
            // NO
            // 
            this.NO.DataPropertyName = "NO";
            this.NO.HeaderText = "NO";
            this.NO.Name = "NO";
            this.NO.ReadOnly = true;
            this.NO.Width = 150;
            // 
            // IMEI_15Bit
            // 
            this.IMEI_15Bit.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
            this.IMEI_15Bit.DataPropertyName = "IMEI";
            this.IMEI_15Bit.HeaderText = "IMEI_15Bit";
            this.IMEI_15Bit.Name = "IMEI_15Bit";
            this.IMEI_15Bit.ReadOnly = true;
            // 
            // PassWord_8Bit
            // 
            this.PassWord_8Bit.DataPropertyName = "Pwd";
            this.PassWord_8Bit.HeaderText = "PassWord_8Bit";
            this.PassWord_8Bit.Name = "PassWord_8Bit";
            this.PassWord_8Bit.ReadOnly = true;
            this.PassWord_8Bit.Width = 300;
            // 
            // contextMenuStrip1
            // 
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.Men_txt,
            this.Men_csv,
            this.Men_xls});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(181, 92);
            // 
            // Men_txt
            // 
            this.Men_txt.Enabled = false;
            this.Men_txt.Image = global::IMEIConvertPwdTools.V1._00.Properties.Resources.txt;
            this.Men_txt.Name = "Men_txt";
            this.Men_txt.Size = new System.Drawing.Size(180, 22);
            this.Men_txt.Text = "Export Data *.txt";
            this.Men_txt.Click += new System.EventHandler(this.Men_txt_Click);
            // 
            // Men_csv
            // 
            this.Men_csv.Enabled = false;
            this.Men_csv.Image = global::IMEIConvertPwdTools.V1._00.Properties.Resources.csv;
            this.Men_csv.Name = "Men_csv";
            this.Men_csv.Size = new System.Drawing.Size(180, 22);
            this.Men_csv.Text = "Export Data *.csv";
            this.Men_csv.Click += new System.EventHandler(this.Men_csv_Click);
            // 
            // Men_xls
            // 
            this.Men_xls.Enabled = false;
            this.Men_xls.Image = global::IMEIConvertPwdTools.V1._00.Properties.Resources.xls;
            this.Men_xls.Name = "Men_xls";
            this.Men_xls.Size = new System.Drawing.Size(180, 22);
            this.Men_xls.Text = "Export Data *.xlsx";
            this.Men_xls.Click += new System.EventHandler(this.Men_xls_Click);
            // 
            // label2
            // 
            this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.label2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.label2.Location = new System.Drawing.Point(3, 92);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(1034, 1);
            this.label2.TabIndex = 0;
            // 
            // timer1
            // 
            this.timer1.Enabled = true;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            // 
            // MainForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1037, 900);
            this.Controls.Add(this.splitContainer1);
            this.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Margin = new System.Windows.Forms.Padding(4);
            this.Name = "MainForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Form1";
            this.SizeChanged += new System.EventHandler(this.MainWinForm_SizeChanged);
            this.Resize += new System.EventHandler(this.MainWinForm_Resize);
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            this.splitContainer1.Panel2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            this.panel1.ResumeLayout(false);
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dtgrive_ImeiData)).EndInit();
            this.contextMenuStrip1.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.SplitContainer splitContainer1;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.ImageList imageList1;
        private System.Windows.Forms.Button btn_Close;
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;
        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3;
        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;
        private System.Windows.Forms.ToolStripStatusLabel t_SystemDateTime;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Timer timer1;
        private System.Windows.Forms.DataGridView dtgrive_ImeiData;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox txt_IEMIFilePath;
        private System.Windows.Forms.Button btn_Import;
        private System.Windows.Forms.DataGridViewTextBoxColumn NO;
        private System.Windows.Forms.DataGridViewTextBoxColumn IMEI_15Bit;
        private System.Windows.Forms.DataGridViewTextBoxColumn PassWord_8Bit;
        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
        private System.Windows.Forms.ToolStripMenuItem Men_txt;
        private System.Windows.Forms.ToolStripMenuItem Men_csv;
        private System.Windows.Forms.ToolStripMenuItem Men_xls;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel5;
        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel6;
        private System.Windows.Forms.ToolStripStatusLabel t_DataCount;
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace IMEIConvertPwdTools.V1._00
{
    public partial class MainForm : Form
    {
        private AutoSizeFormClass asc = null;
        private AutoSetControlSize ass = null;
        private List<string> iMEIdata;
        private List<IMEIConvertPwdEntity> iMEIConvertPwdEntities;

        public MainForm()
        {
            InitializeComponent();
            ass = new AutoSetControlSize(this, this.Width, this.Height);
        }


        #region 窗体自适应
        private void MainWinForm_SizeChanged(object sender, EventArgs e)
        {
            asc = new AutoSizeFormClass(this);
            asc.controlAutoSize(this);
        }

        private void MainWinForm_Resize(object sender, EventArgs e)
        {
            ass.setControls((this.Width) / ass.X, (this.Height) / ass.Y, this);
        }
        #endregion

        #region 窗体移动
        private Point mouseOff;//鼠标移动位置变量
        private bool leftFlag;//标签是否为左键

        private void Frm_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                mouseOff = new Point(-e.X, -e.Y); //得到变量的值
                leftFlag = true;                  //点击左键按下时标注为true;
            }
        }

        private void Frm_MouseMove(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
                Point mouseSet = Control.MousePosition;
                mouseSet.Offset(mouseOff.X, mouseOff.Y);  //设置移动后的位置
                Location = mouseSet;
            }
        }

        private void Frm_MouseUp(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
                leftFlag = false;//释放鼠标后标注为false;
            }
        }
        #endregion

        #region 同步系统时间
        private void timer1_Tick(object sender, EventArgs e)
        {
            t_SystemDateTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
        #endregion

        #region 关闭窗体
        private void btn_Close_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Confirm Exit!!", "Remind",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
            if (dialogResult==DialogResult.Yes)
                Application.Exit();
        }
        #endregion

        #region 导入数据
        private void btn_Import_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Multiselect = false;//该值确定是滞可以选择多个文件
            dialog.Title = "Please select file";
            dialog.Filter = "(*.txt)|*.txt";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                txt_IEMIFilePath.Text = dialog.FileName;
                if (this.ReadImeiFileData(txt_IEMIFilePath.Text))
                {
                    if (this.BatchImeiConvertPwsData(iMEIdata))
                    {
                        dtgrive_ImeiData.DataSource = new List<IMEIConvertPwdEntity>();
                        dtgrive_ImeiData.DataSource = iMEIConvertPwdEntities;
                    }
                }
            }
        }
        #endregion

        #region 批量转换ImeiData
        private bool BatchImeiConvertPwsData(List<string> data)
        {
            iMEIConvertPwdEntities = new List<IMEIConvertPwdEntity>();
            for (int i = 0; i < data.Count; i++)
            {
                if (this.ImeiConvertPwsData(data[i]))
                {
                    iMEIConvertPwdEntities.Add(new IMEIConvertPwdEntity()
                    {
                        NO = i + 1,
                        IMEI = data[i],
                        Pwd = temp
                    });
                }
                else
                    return false;
            }
            if (iMEIConvertPwdEntities.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region 单项转换Imei 数据
        private string temp;
        private bool ImeiConvertPwsData(string strdata)
        {
            temp = string.Empty;
            for (int i = 0; i < strdata.Length - 1; i += 2)
            {
                try
                {
                    temp += ((Convert.ToInt32(strdata[i].ToString()) + Convert.ToInt32(strdata[i + 1].ToString())) % 10).ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    return false;
                }
            }
            temp += strdata[0].ToString();
            if (temp != string.Empty)
                return true;
            return false;
        }
        #endregion



        #region 读取IMEI文件数据
        private bool ReadImeiFileData(string fileName)
        {
            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader(fs, Encoding.Default))
                {
                    string temp = string.Empty;
                    iMEIdata = new List<string>();
                    while ((temp = sr.ReadLine()) != null)
                    {
                        if (temp.Length != 15)
                        {
                            MessageBox.Show($"IMEI:{temp}Format error!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return false;
                        }
                        else
                        {
                            iMEIdata.Add(temp.Trim());
                        }
                    }
                    return true;
                }
            }
            return false;
        }
        #endregion

        #region 表格内容更新事件
        private void dtgrive_ImeiData_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            t_DataCount.Text = iMEIConvertPwdEntities.Count.ToString() + "Pcs";
            Men_csv.Enabled = iMEIConvertPwdEntities.Count > 0 ? true : false;
            Men_txt.Enabled = iMEIConvertPwdEntities.Count > 0 ? true : false;
            Men_xls.Enabled = iMEIConvertPwdEntities.Count > 0 ? true : false;
        }
        #endregion

        #region 导出txt
        private void Men_txt_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Application.StartupPath;// @"C:\Users\Administrator\Desktop";
            saveFileDialog.Filter = @"*.txt|*.txt";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                using (FileStream fs = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write))
                {
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        sw.WriteLine("NO|IMEI_15Bit|Pws_8Bit");
                        iMEIConvertPwdEntities.ForEach((i) => { sw.WriteLine(i.NO + "|" + i.IMEI + "|" + i.Pwd); });
                    }
                    MessageBox.Show("Export the complete!!", "Remind",MessageBoxButtons.OK,MessageBoxIcon.Information);
                }
            }
        }
        #endregion

        #region 导出xls
        private void Men_xls_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Application.StartupPath;// @"C:\Users\Administrator\Desktop";
            saveFileDialog.Filter = @"*.xlsx|*.xlsx";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("NO", typeof(Int32));
                dt.Columns.Add("IMEI_15Bit", typeof(string));
                dt.Columns.Add("Pws_8Bit", typeof(string));
                iMEIConvertPwdEntities.ForEach((i) => {
                    DataRow dr = dt.NewRow();
                    dr[0] = i.NO;
                    dr[1] = i.IMEI;
                    dr[2] = i.Pwd;
                    dt.Rows.Add(dr);
                });
                ExcelHelper.TableToExcel(dt, saveFileDialog.FileName);
                MessageBox.Show("Export the complete!!", "Remind", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        #endregion

        #region 导出csv
        private void Men_csv_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Application.StartupPath;// @"C:\Users\Administrator\Desktop";
            saveFileDialog.Filter = @"*.csv|*.csv";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("NO", typeof(Int32));
                dt.Columns.Add("IMEI_15Bit", typeof(string));
                dt.Columns.Add("Pws_8Bit", typeof(string));
                iMEIConvertPwdEntities.ForEach((i) => {
                    DataRow dr = dt.NewRow();
                    dr[0] = i.NO;
                    dr[1] = i.IMEI;
                    dr[2] = i.Pwd;
                    dt.Rows.Add(dr);
                });
                CSVFileHelper.SaveCSV(dt, saveFileDialog.FileName);
                MessageBox.Show("Export the complete!!", "Remind", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        #endregion
    }
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace IMEIConvertPwdTools.V1._00
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
    }
}

将24转换成8位图的过程中,需要用到调色板。调色板是一个包含256种颜色的表格,每个颜色都由三个8位组成的RGB值来表示。具体的转换步骤如下: 1. 创建一个空白的8位图,并设置它的宽度和高度与原始24图相同。 2. 创建一个调色板,其中包含256种颜色。可以使用ColorPalette类来创建调色板。 3. 遍历原始24图的每个像素,将它的RGB值转换成一个0到255之间的整数,然后将该整数作为调色板中对应颜色的索引,将索引值写入新的8位图中。 4. 将调色板与新的8位图相关联,使用Bitmap类的SetPixel和GetPixel方法可以完成这一步操作。 5. 最后保存新的8位图即可。 下面是一个C#代码示例,可以将24转换成8位图: ```csharp public static Bitmap ConvertTo8bpp(Bitmap bmp) { // 创建一个新的8位图 Bitmap newBmp = new Bitmap(bmp.Width, bmp.Height, PixelFormat.Format8bppIndexed); // 创建调色板 ColorPalette pal = newBmp.Palette; for (int i = 0; i < 256; i++) { pal.Entries[i] = Color.FromArgb(i, i, i); } newBmp.Palette = pal; // 遍历原始图的每个像素,并将RGB值转换成索引 for (int y = 0; y < bmp.Height; y++) { for (int x = 0; x < bmp.Width; x++) { Color color = bmp.GetPixel(x, y); int index = (int)(0.299 * color.R + 0.587 * color.G + 0.114 * color.B); newBmp.SetPixel(x, y, Color.FromArgb(index, index, index)); } } return newBmp; } ``` 在这个示例中,使用了YUV颜色空间的转换公式将RGB值转换成了索引。可以根据具体需求使用不同的转换公式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值