Esempio n. 1
0
        private void ButtonBindFaceData(Button btn, FaceData fdata)
        {
            Image img = null;

            if (string.IsNullOrEmpty(fdata.Path22))
            {
                img = ThumbHelper.GetThumb(fdata.PageInThumb, fdata.XPosInThumb, fdata.YPosInThumb);
            }
            else
            {
                img = Bitmap.FromFile(fdata.Path22);
            }
            var bmp = new Bitmap(img, new Size(buttonsize, buttonsize));

            btn.Image = bmp;
            btn.Text  = fdata.Number.ToString("D5");
            if (fdata.IsCustomed)
            {
                btn.ForeColor = Color.Red;
            }
            else
            {
                btn.ForeColor = Color.GreenYellow;
            }
        }
Esempio n. 2
0
 private void btnSplit22_Click(object sender, EventArgs e)
 {
     using (var odlg = new OpenFileDialog())
     {
         odlg.Filter           = "Bitmap File|*.BMP";
         odlg.CheckFileExists  = true;
         odlg.RestoreDirectory = false;
         odlg.Multiselect      = false;
         odlg.Title            = "请选择待拆分的22图片";
         if (odlg.ShowDialog(this) == DialogResult.OK)
         {
             using (var fdlg = new FolderBrowserDialog())
             {
                 fdlg.ShowNewFolderButton = true;
                 if (fdlg.ShowDialog(this) == DialogResult.OK)
                 {
                     var targetDir = fdlg.SelectedPath;
                     var thumbs    = ThumbHelper.Img2Thumb(odlg.FileName);
                     var dmyname   = DateTime.Now.ToString("yyyyMMddHHmmss") + "_";
                     for (int i = 0; i < thumbs.Count; i++)
                     {
                         OutputHelper.SaveImage(thumbs[i], dmyname + (i + 1).ToString("D3") + ".bmp", targetDir);
                     }
                     var dr = MessageBox.Show("已保存,是否打开文件夹", "已保存", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                     if (dr == DialogResult.Yes)
                     {
                         System.Diagnostics.Process.Start(targetDir);
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
        public static void Output(string outputDir)
        {
            var fdatas = FaceDataHelper.GetFaceDatas();
            var outputThumbFaceDatas = new List <FaceData>();

            foreach (var fdata in fdatas)
            {
                if (fdata.IsCustomed)
                {
                    CopyFile(fdata.Path13, fdata.Filename13, outputDir);
                    CopyFile(fdata.Path18, fdata.Filename18, outputDir);
                    CopyFile(fdata.Path20, fdata.Filename20, outputDir);
                    CopyFile(fdata.Path81, fdata.Filename81, outputDir);
                    CopyFile(fdata.Path82, fdata.Filename82, outputDir);
                    CopyFile(fdata.Path83, fdata.Filename83, outputDir);
                    if (string.IsNullOrEmpty(fdata.Path22) == false)
                    {
                        outputThumbFaceDatas.Add(fdata);
                    }
                }
            }

            if (outputThumbFaceDatas.Count > 0)
            {
                Dictionary <int, Image> drawImageCache = new Dictionary <int, Image>();
                List <int> pageChanged = new List <int>();
                foreach (var fdata in outputThumbFaceDatas)
                {
                    var pageno = fdata.PageInThumb;
                    if (drawImageCache.Keys.Contains(pageno) == false)
                    {
                        drawImageCache[fdata.PageInThumb] = new Bitmap(ThumbHelper.GetThumbPageImage(fdata.PageInThumb));
                    }
                    var g    = Graphics.FromImage(drawImageCache[pageno]);
                    var simg = Bitmap.FromFile(fdata.Path22);
                    g.DrawImage(simg,
                                new Rectangle(
                                    fdata.XPosInThumb * ThumbHelper.BLOCK_WIDTH,
                                    fdata.YPosInThumb * ThumbHelper.BLOCK_HEIGHT,
                                    ThumbHelper.BLOCK_WIDTH,
                                    ThumbHelper.BLOCK_HEIGHT),
                                new Rectangle(0, 0, ThumbHelper.BLOCK_WIDTH, ThumbHelper.BLOCK_HEIGHT),
                                GraphicsUnit.Pixel);
                    g.Dispose();
                    if (pageChanged.Contains(pageno) == false)
                    {
                        pageChanged.Add(pageno);
                    }
                }
                foreach (var pageno in pageChanged)
                {
                    SaveImage(drawImageCache[pageno], "00000022_0000" + pageno + ".bmp", outputDir);
                }
            }
            FaceDataHelper.SaveMyData();
        }
Esempio n. 4
0
        public MainForm()
        {
            InitializeComponent();
            this.flowPanels = new FlowLayoutPanel[] {
                this.flowLayoutPanel1, this.flowLayoutPanel2,
                this.flowLayoutPanel3, this.flowLayoutPanel4,
                this.flowLayoutPanel5, this.flowLayoutPanel6,
                this.flowLayoutPanel7, this.flowLayoutPanel8
            };
            var datas = FaceDataHelper.GetFaceDatas();

            foreach (var data in datas)
            {
                var ctrl = new Button();
                this.ButtonBindFaceData(ctrl, data);
                ctrl.Width    = buttonsize;
                ctrl.Height   = buttonsize;
                ctrl.Tag      = data;
                ctrl.Click   += Ctrl_Click;
                ctrl.MouseUp += Ctrl_MouseUp;
                //ctrl.ForeColor = Color.GreenYellow;
                ctrl.Font      = new Font(new FontFamily("宋体"), 7, FontStyle.Bold);
                ctrl.TextAlign = ContentAlignment.BottomCenter;
                var pnl = this.flowPanels[data.PageInThumb - 1];
                ctrl.Margin = new Padding(0);
                pnl.Controls.Add(ctrl);
                if (data.Number % 10 == 0)
                {
                    var page = ThumbHelper.GetThumbPage(data.PageInThumb);
                    if (data.XPosInThumb + 1 == page.ColSize)
                    {
                        pnl.SetFlowBreak(ctrl, true);
                    }
                }
                ctrl.Show();
            }
            dlg = new Pig313PKFaceToolPlus.EditForm();
        }
Esempio n. 5
0
 public static Image GetThumbPageImage(int pageno)
 {
     if (imgcache == null)
     {
         imgcache = new Dictionary <int, Image>();
     }
     if (imgcache.Keys.Contains(pageno) == false)
     {
         imgcache[pageno] = Bitmap.FromStream(ResourceControl.GetResourceStream(ThumbHelper.GetThumbPageFileName(pageno)));
         //imgcache[pageno] = Bitmap.FromFile(ThumbHelper.GetThumbPageFileName(pageno));
     }
     return(imgcache[pageno]);
 }