MakeImage() public method

public MakeImage ( Image &image, Image &imageOriginal, float zoom, List labels = null ) : bool
image Image
imageOriginal Image
zoom float
labels List
return bool
Ejemplo n.º 1
0
        void doOutput()
        {
            string log = "";

            Invoke(new Action(() => outPgBar.Maximum = wsp.Store.Filenames.Length));

            try
            {
                foreach (string key in wsp.Store.Filenames)
                {
                    if (checkBoxJumpNoNum.Checked && wsp.Store[key].Count == 0)
                    {
                    }
                    else
                    {
                        string outputFilename = folderBrowserDialog.SelectedPath + @"\" + key;
                        outputFilename = replaceExtension(outputFilename, radioButtonPNG.Checked ? ".png" : ".jpg");

                        string inputFilename = wsp.DirPath + @"\" + key;
                        try
                        {
                            Image in_img  = Image.FromFile(inputFilename);
                            Image out_img = null;
                            var   rslt    = pv.MakeImage(ref out_img, ref in_img, Convert.ToSingle(textBox.Text), wsp.Store[key]);
                            in_img.Dispose();
                            if (!rslt)
                            {
                                throw new FormatException();
                            }
                            else
                            {
                                using (Stream stream = new FileStream(outputFilename, FileMode.Create))
                                {
                                    out_img.Save(stream, radioButtonPNG.Checked ? ImageFormat.Png : ImageFormat.Jpeg);
                                    out_img.Dispose();
                                }
                                //stream.Close();
                            }
                        }
                        catch
                        { log += "\n" + StringResources.GetValue("can_not_output_file") + outputFilename; }
                    }
                    Invoke(new Action(() => ++ outPgBar.Value));
                }
                log += "\n\n" + StringResources.GetValue("output_complete");
            }
            catch (ThreadAbortException)
            { log += "\n\n" + StringResources.GetValue("output_aborted"); }
            catch (Exception)
            { log += "\n\n" + StringResources.GetValue("output_fail"); }
            finally
            {
                try
                {
                    MessageBox.Show(log);
                    Invoke(new Action(() => { if (button != null)
                                              {
                                                  button.Enabled = true;
                                              }
                                      }));
                    Invoke(new Action(() => { if (buttonAbort != null)
                                              {
                                                  buttonAbort.Enabled = false;
                                              }
                                      }));
                    Invoke(new Action(() => { if (outPgBar != null)
                                              {
                                                  outPgBar.Value = 0;
                                              }
                                      }));
                }
                catch { /* 窗口销毁后发生的线程冲突之 InvalidOperationException 强行不要了,嗯 */ }
            }
        }