当前位置: 首页>>代码示例>>C#>>正文


C# Surface.GetImageForExport方法代码示例

本文整理汇总了C#中Greenshot.Drawing.Surface.GetImageForExport方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.GetImageForExport方法的具体用法?C# Surface.GetImageForExport怎么用?C# Surface.GetImageForExport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Greenshot.Drawing.Surface的用法示例。


在下文中一共展示了Surface.GetImageForExport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleCapture

        private void HandleCapture(string fullPath)
        {
            if (capture == null)
             {
            StopCapturing(true);
             }

             // Flag to see if the image was "exported" so the FileEditor doesn't
             // ask to save the file as long as nothing is done.
             bool outputMade = false;

             // Make sure the user sees that the capture is made
             if (capture.CaptureDetails.CaptureMode != CaptureMode.File && capture.CaptureDetails.CaptureMode != CaptureMode.Clipboard)
             {
            DoCaptureFeedback();
             }
             else
             {
            // If File || Clipboard
            // Maybe not "made" but the original is still there... somehow
            outputMade = true;
             }

             LOG.Debug("A capture of: " + capture.CaptureDetails.Title);

             // Create event OnCaptureTaken for all Plugins
             PluginHelper.instance.CreateCaptureTakenEvent(capture);

             // check if someone has passed a handler
             if (capture.CaptureDetails.CaptureHandler != null)
             {
            CaptureTakenEventArgs eventArgs = new CaptureTakenEventArgs(capture);
            capture.CaptureDetails.CaptureHandler(this, eventArgs);
             }
             else if (capture.CaptureDetails.CaptureDestinations == null || capture.CaptureDetails.CaptureDestinations.Count == 0)
             {
            AddConfiguredDestination(capture);
             }

             // Create Surface with capture, this way elements can be added automatically (like the mouse cursor)
             Surface surface = new Surface(capture);

             // As the surfaces copies the reference to the image, make sure the image is not being disposed (a trick to save memory)
             capture.Image = null;

             // Call plugins to do something with the screenshot
             PluginHelper.instance.CreateSurfaceFromCaptureEvent(capture, surface);

             // Disable capturing
             captureMode = CaptureMode.None;

             // Retrieve important information from the Capture object
             ICaptureDetails captureDetails = capture.CaptureDetails;
             List<CaptureDestination> captureDestinations = capture.CaptureDetails.CaptureDestinations;

             // Dispose the capture, we don't need it anymore (the surface copied all information and we got the title (if any)).
             capture.Dispose();
             capture = null;

             // Want to add more stuff to the surface?? DO IT HERE!
             int destinationsCount = captureDestinations.Count;
             if (captureDestinations.Contains(CaptureDestination.Editor))
             {
            destinationsCount--;
             }
             if (destinationsCount > 0)
             {
            // Create Image for writing/printing etc and use "using" as all code paths either output the image or copy the image
            using (Image image = surface.GetImageForExport())
            {
               // Flag to detect if we need to create a temp file for the email
               // or use the file that was written
               bool fileWritten = false;

               if (captureDestinations.Contains(CaptureDestination.espUrl))
               {
                  string title = captureDetails.Title;
                  if (string.IsNullOrEmpty(title))
                  {
                     title = "screen_" + captureDetails.DateTime.ToString("yyyyMMddHHmmssfff");
                  }

                  using (var ms = new MemoryStream())
                  {
                     ImageOutput.SaveToStream(image, ms, OutputFormat.png, 1);
                     ms.Seek(0, SeekOrigin.Begin);
                     new EspUrlClient().Upload(ms, title + ".png");
                  }
               }

               if (captureDestinations.Contains(CaptureDestination.File))
               {
                  string pattern = conf.OutputFileFilenamePattern;
                  if (pattern == null || string.IsNullOrEmpty(pattern.Trim()))
                  {
                     pattern = "espurl ${capturetime}";
                  }
                  string filename = FilenameHelper.GetFilenameFromPattern(pattern, conf.OutputFileFormat, captureDetails);
                  string filepath = FilenameHelper.FillVariables(conf.OutputFilePath, false);
                  fullPath = Path.Combine(filepath, filename);
//.........这里部分代码省略.........
开发者ID:eservicepartner,项目名称:espUrl,代码行数:101,代码来源:CaptureForm.cs


注:本文中的Greenshot.Drawing.Surface.GetImageForExport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。