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


C# ISurface.GetImageForExport方法代码示例

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


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

示例1: ExportCapture

 public override bool ExportCapture(ISurface surface, ICaptureDetails captureDetails)
 {
     using (Image image = surface.GetImageForExport()) {
         bool uploaded = plugin.Upload(captureDetails, image);
         if (uploaded) {
             surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "Exported to Dropbox");
             surface.Modified = false;
         }
         return uploaded;
     }
 }
开发者ID:ploufs,项目名称:Greenshot-DropBox-Plugin,代码行数:11,代码来源:DropboxDestination.cs

示例2: ExportCapture

		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			CoreConfiguration config = IniConfig.GetIniSection<CoreConfiguration>();
			OutputSettings outputSettings = new OutputSettings();

			string file = FilenameHelper.GetFilename(OutputFormat.png, null);
			string filePath = Path.Combine(config.OutputFilePath, file);
			using (FileStream stream = new FileStream(filePath, FileMode.Create)) {
				using (Image image = surface.GetImageForExport()) {
					ImageOutput.SaveToStream(image, stream, outputSettings);
				}
			}
			exportInformation.Filepath = filePath;
			exportInformation.ExportMade = true;
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
开发者ID:logtcn,项目名称:greenshot,代码行数:17,代码来源:SimpleOutputDestination.cs

示例3: CreateImageFromSurface

        /// <summary>
        /// Create an image from a surface with the settings from the output settings applied
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="outputSettings"></param>
        /// <param name="imageToSave"></param>
        /// <returns>true if the image must be disposed</returns>
        public static bool CreateImageFromSurface(ISurface surface, SurfaceOutputSettings outputSettings, out Image imageToSave)
        {
            bool disposeImage = false;

            if (outputSettings.Format == OutputFormat.greenshot || outputSettings.SaveBackgroundOnly)
            {
                // We save the image of the surface, this should not be disposed
                imageToSave = surface.Image;
            }
            else
            {
                // We create the export image of the surface to save
                imageToSave = surface.GetImageForExport();
                disposeImage = true;
            }

            // The following block of modifications should be skipped when saving the greenshot format, no effects or otherwise!
            if (outputSettings.Format == OutputFormat.greenshot)
            {
                return disposeImage;
            }
            Image tmpImage;
            if (outputSettings.Effects != null && outputSettings.Effects.Count > 0)
            {
                // apply effects, if there are any
                using (Matrix matrix = new Matrix())
                {
                    tmpImage = ImageHelper.ApplyEffects(imageToSave, outputSettings.Effects, matrix);
                }
                if (tmpImage != null)
                {
                    if (disposeImage)
                    {
                        imageToSave.Dispose();
                    }
                    imageToSave = tmpImage;
                    disposeImage = true;
                }
            }

            return disposeImage;
        }
开发者ID:snakems,项目名称:ShareX,代码行数:49,代码来源:ImageOutput.cs

示例4: ExportCapture

		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(Designation, Description);
			// Make sure we collect the garbage before opening the screenshot
			GC.Collect();
			GC.WaitForPendingFinalizers();

			bool modified = surface.Modified;
			if (editor == null) {
				if (editorConfiguration.ReuseEditor) {
					foreach(IImageEditor openedEditor in ImageEditorForm.Editors) {
						if (!openedEditor.Surface.Modified) {
							openedEditor.Surface = surface;
							exportInformation.ExportMade = true;
							break;
						}
					}
				}
				if (!exportInformation.ExportMade) {
					try {
						ImageEditorForm editorForm = new ImageEditorForm(surface, !surface.Modified); // Output made??

						if (!string.IsNullOrEmpty(captureDetails.Filename)) {
							editorForm.SetImagePath(captureDetails.Filename);
						}
						editorForm.Show();
						editorForm.Activate();
						LOG.Debug("Finished opening Editor");
						exportInformation.ExportMade = true;
					} catch (Exception e) {
						LOG.Error(e);
						exportInformation.ErrorMessage = e.Message;
					}
				}
			} else {
				try {
					using (Image image = surface.GetImageForExport()) {
						editor.Surface.AddImageContainer(image, 10, 10);
					}
					exportInformation.ExportMade = true;
				} catch (Exception e) {
					LOG.Error(e);
					exportInformation.ErrorMessage = e.Message;
				}
			}
			ProcessExport(exportInformation, surface);
			// Workaround for the modified flag when using the editor.
			surface.Modified = modified;
			return exportInformation;
		}
开发者ID:logtcn,项目名称:greenshot,代码行数:49,代码来源:EditorDestination.cs

示例5: ExportCapture

        public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            bool outputMade = false;
            string pattern = "${title}";
            if (string.IsNullOrEmpty(pattern))
            {
                pattern = "greenshot ${capturetime}";
            }
            string filename = FilenameHelper.GetFilenameFromPattern(pattern, conf.OutputFileFormat, captureDetails);
            string filepath = FilenameHelper.FillVariables(conf.OutputFilePath, false);
            string fullPath = Path.Combine(filepath, filename);

            // Catching any exception to prevent that the user can't write in the directory.
            // This is done for e.g. bugs #2974608, #2963943, #2816163, #2795317, #2789218, #3004642
            using (Image image = surface.GetImageForExport())
            {
                try
                {
                    // TODO: For now we overwrite, but this should be fixed some time
                    ImageOutput.Save(image, fullPath, true);
                    outputMade = true;
                }
                catch (Exception e)
                {
                    LOG.Error("Error saving screenshot!", e);
                    // Show the problem
                    MessageBox.Show(Language.GetString(LangKey.error_save), Language.GetString(LangKey.error));
                    // when save failed we present a SaveWithDialog
                    fullPath = ImageOutput.SaveWithDialog(image, captureDetails);
                    outputMade = (fullPath != null);
                }
            }
            // Don't overwite filename if no output is made
            if (outputMade)
            {
                surface.LastSaveFullPath = fullPath;
                surface.Modified = false;
                captureDetails.Filename = fullPath;
                surface.SendMessageEvent(this, SurfaceMessageTyp.FileSaved, Language.GetFormattedString(LangKey.editor_imagesaved, surface.LastSaveFullPath));
            }
            else
            {
                surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "");
            }
            return outputMade;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:46,代码来源:FileDestination.cs

示例6: ExportCapture

        public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            try {
                using (Image image = surface.GetImageForExport()) {
                    ClipboardHelper.SetClipboardData(image);
                    surface.Modified = false;
                }
                surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetString(LangKey.editor_storedtoclipboard));
                return true;
            } catch (Exception) {
                surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetString(LangKey.editor_clipboardfailed));
            }

            return false;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:15,代码来源:ClipboardDestination.cs

示例7: ExportCapture

 public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
 {
     string savedTo = null;
     using (Image image = surface.GetImageForExport()) {
         // Bug #2918756 don't overwrite path if SaveWithDialog returns null!
         savedTo = ImageOutput.SaveWithDialog(image, captureDetails);
         if (savedTo != null) {
             surface.Modified = false;
             surface.LastSaveFullPath = savedTo;
             captureDetails.Filename = savedTo;
             surface.SendMessageEvent(this, SurfaceMessageTyp.FileSaved, Language.GetFormattedString(LangKey.editor_imagesaved, surface.LastSaveFullPath));
         }
     }
     return savedTo != null;
 }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:15,代码来源:FileWithDialogDestination.cs

示例8: ExportCapture

        public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            string tmpFile = captureDetails.Filename;
            if (tmpFile == null || surface.Modified) {
                using (Image image = surface.GetImageForExport()) {
                    tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
                }
            }
            if (documentCaption != null) {
                WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
            } else {
                if (!manuallyInitiated) {
                    List<string> documents = WordExporter.GetWordDocuments();
                    if (documents != null && documents.Count > 0) {
                        List<IDestination> destinations = new List<IDestination>();
                        destinations.Add(new WordDestination());
                        foreach (string document in documents) {
                            destinations.Add(new WordDestination(document));
                        }
                        ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
                        PickerDestination.ShowMenuAtCursor(menu);
                        return false;
                    }
                }
                WordExporter.InsertIntoNewDocument(tmpFile);
            }
            surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
            surface.Modified = false;

            return true;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:31,代码来源:WordDestination.cs

示例9: CreateImageFromSurface

        /// <summary>
        /// Create an image from a surface with the settings from the output settings applied
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="outputSettings"></param>
        /// <param name="imageToSave"></param>
        /// <returns>true if the image must be disposed</returns>
        public static bool CreateImageFromSurface(ISurface surface, SurfaceOutputSettings outputSettings, out Image imageToSave)
        {
            bool disposeImage = false;
            ImageFormat imageFormat = null;
            switch (outputSettings.Format)
            {
                case OutputFormat.bmp:
                    imageFormat = ImageFormat.Bmp;
                    break;
                case OutputFormat.gif:
                    imageFormat = ImageFormat.Gif;
                    break;
                case OutputFormat.jpg:
                    imageFormat = ImageFormat.Jpeg;
                    break;
                case OutputFormat.tiff:
                    imageFormat = ImageFormat.Tiff;
                    break;
                case OutputFormat.greenshot:
                case OutputFormat.png:
                default:
                    imageFormat = ImageFormat.Png;
                    break;
            }

            if (outputSettings.Format == OutputFormat.greenshot || outputSettings.SaveBackgroundOnly)
            {
                // We save the image of the surface, this should not be disposed
                imageToSave = surface.Image;
            }
            else
            {
                // We create the export image of the surface to save
                imageToSave = surface.GetImageForExport();
                disposeImage = true;
            }

            // The following block of modifications should be skipped when saving the greenshot format, no effects or otherwise!
            if (outputSettings.Format != OutputFormat.greenshot)
            {
                Image tmpImage;
                if (outputSettings.Effects != null && outputSettings.Effects.Count > 0)
                {
                    // apply effects, if there are any
                    Point ignoreOffset;
                    tmpImage = ImageHelper.ApplyEffects((Bitmap)imageToSave, outputSettings.Effects, out ignoreOffset);
                    if (tmpImage != null)
                    {
                        if (disposeImage)
                        {
                            imageToSave.Dispose();
                        }
                        imageToSave = tmpImage;
                        disposeImage = true;
                    }
                }

                // check for color reduction, forced or automatically, only when the DisableReduceColors is false
                if (!outputSettings.DisableReduceColors && (conf.OutputFileAutoReduceColors || outputSettings.ReduceColors))
                {
                    bool isAlpha = Image.IsAlphaPixelFormat(imageToSave.PixelFormat);
                    if (outputSettings.ReduceColors || (!isAlpha && conf.OutputFileAutoReduceColors))
                    {
                        using (WuQuantizer quantizer = new WuQuantizer((Bitmap)imageToSave))
                        {
                            int colorCount = quantizer.GetColorCount();
                            LOG.InfoFormat("Image with format {0} has {1} colors", imageToSave.PixelFormat, colorCount);
                            if (outputSettings.ReduceColors || colorCount < 256)
                            {
                                try
                                {
                                    LOG.Info("Reducing colors on bitmap to 256.");
                                    tmpImage = quantizer.GetQuantizedImage(256);
                                    if (disposeImage)
                                    {
                                        imageToSave.Dispose();
                                    }
                                    imageToSave = tmpImage;
                                    // Make sure the "new" image is disposed
                                    disposeImage = true;
                                }
                                catch (Exception e)
                                {
                                    LOG.Warn("Error occurred while Quantizing the image, ignoring and using original. Error: ", e);
                                }
                            }
                        }
                    }
                    else if (isAlpha && !outputSettings.ReduceColors)
                    {
                        LOG.Info("Skipping 'optional' color reduction as the image has alpha");
                    }
                }
//.........这里部分代码省略.........
开发者ID:yoykiee,项目名称:ShareX,代码行数:101,代码来源:ImageOutput.cs

示例10: ExportCapture

 public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
 {
     string tmpFile = captureDetails.Filename;
     Size imageSize = Size.Empty;
     if (tmpFile == null || surface.Modified) {
         using (Image image = surface.GetImageForExport()) {
             tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
             imageSize = image.Size;
         }
     }
     if (presentationName != null) {
         PowerpointExporter.ExportToPresentation(presentationName, tmpFile, imageSize, captureDetails.Title);
     } else {
         if (!manuallyInitiated) {
             List<string> presentations = PowerpointExporter.GetPowerpointPresentations();
             if (presentations != null && presentations.Count > 0) {
                 List<IDestination> destinations = new List<IDestination>();
                 destinations.Add(new PowerpointDestination());
                 foreach (string presentation in presentations) {
                     destinations.Add(new PowerpointDestination(presentation));
                 }
                 ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
                 PickerDestination.ShowMenuAtCursor(menu);
                 return false;
             }
         }
         PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
     }
     surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
     surface.Modified = false;
     return true;
 }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:32,代码来源:PowerpointDestination.cs

示例11: ExportCapture

        public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            if (editor == null) {
                // Make sure we collect the garbage before opening the screenshot
                GC.Collect();
                GC.WaitForPendingFinalizers();

                try {
                    ImageEditorForm editorForm = new ImageEditorForm(surface, !surface.Modified); // Output made??

                    if (!string.IsNullOrEmpty(captureDetails.Filename)) {
                        editorForm.SetImagePath(captureDetails.Filename);
                    }
                    editorForm.Show();
                    editorForm.Activate();
                    LOG.Debug("Finished opening Editor");
                    return true;
                } catch (Exception e) {
                    LOG.Error(e);
                }
            } else {
                using (Bitmap image = (Bitmap)surface.GetImageForExport()) {
                    editor.Surface.AddBitmapContainer(image, 10, 10);
                }
                surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
            }
            return false;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:28,代码来源:EditorDestination.cs

示例12: Upload

		/// <summary>
		/// Upload the capture to imgur
		/// </summary>
		/// <param name="captureDetails"></param>
		/// <param name="image"></param>
		/// <param name="uploadURL">out string for the url</param>
		/// <returns>true if the upload succeeded</returns>
		public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, out string uploadURL) {
			SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
			try {
				string filename = Path.GetFileName(FilenameHelper.GetFilenameFromPattern(config.FilenamePattern, config.UploadFormat, captureDetails));
				ImgurInfo imgurInfo = null;

				// Run upload in the background
				new PleaseWaitForm().ShowAndWait("Imgur plug-in", Language.GetString("imgur", LangKey.communication_wait),
					delegate() {
						imgurInfo = ImgurUtils.UploadToImgur(surfaceToUpload, outputSettings, captureDetails.Title, filename);
						if (imgurInfo != null && config.AnonymousAccess) {
							LOG.InfoFormat("Storing imgur upload for hash {0} and delete hash {1}", imgurInfo.Hash, imgurInfo.DeleteHash);
							config.ImgurUploadHistory.Add(imgurInfo.Hash, imgurInfo.DeleteHash);
							config.runtimeImgurHistory.Add(imgurInfo.Hash, imgurInfo);
							CheckHistory();
						}
					}
				);

				if (imgurInfo != null) {
					// TODO: Optimize a second call for export
					using (Image tmpImage = surfaceToUpload.GetImageForExport()) {
						imgurInfo.Image = ImageHelper.CreateThumbnail(tmpImage, 90, 90);
					}
					IniConfig.Save();

					if (config.UsePageLink)
					{
						uploadURL = imgurInfo.Page;
					}
					else
					{
						uploadURL = imgurInfo.Original;
					}
					if (!string.IsNullOrEmpty(uploadURL) && config.CopyLinkToClipboard)
					{
						try
						{
							ClipboardHelper.SetClipboardData(uploadURL);

						}
						catch (Exception ex)
						{
							LOG.Error("Can't write to clipboard: ", ex);
							uploadURL = null;
						}
					}
					return true;
				}
			} catch (Exception e) {
				LOG.Error("Error uploading.", e);
				MessageBox.Show(Language.GetString("imgur", LangKey.upload_failure) + " " + e.Message);
			}
			uploadURL = null;
			return false;
		}
开发者ID:logtcn,项目名称:greenshot,代码行数:63,代码来源:ImgurPlugin.cs

示例13: ExportCapture

        public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            if (!isOutlookUsed) {
                using (Image image = surface.GetImageForExport()) {
                    MapiMailMessage.SendImage(image, captureDetails);
                    surface.Modified = false;
                    surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "Exported to " + mapiClient);
                }
                return true;
            }

            // Outlook logic
            string tmpFile = captureDetails.Filename;
            if (tmpFile == null || surface.Modified) {
                using (Image image = surface.GetImageForExport()) {
                    tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
                }
            } else {
                LOG.InfoFormat("Using already available file: {0}", tmpFile);
            }

            // Create a attachment name for the image
            string attachmentName = captureDetails.Title;
            if (!string.IsNullOrEmpty(attachmentName)) {
                attachmentName = attachmentName.Trim();
            }
            // Set default if non is set
            if (string.IsNullOrEmpty(attachmentName)) {
                attachmentName = "Greenshot Capture";
            }
            // Make sure it's "clean" so it doesn't corrupt the header
            attachmentName = Regex.Replace(attachmentName, @"[^\x20\d\w]", "");

            if (outlookInspectorCaption != null) {
                OutlookEmailExporter.ExportToInspector(outlookInspectorCaption, tmpFile, attachmentName);
            } else {
                if (!manuallyInitiated) {
                    Dictionary<string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets(conf.OutlookAllowExportInMeetings);
                    if (inspectorCaptions != null && inspectorCaptions.Count > 0) {
                        List<IDestination> destinations = new List<IDestination>();
                        destinations.Add(new EmailDestination());
                        foreach (string inspectorCaption in inspectorCaptions.Keys) {
                            destinations.Add(new EmailDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
                        }
                        ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
                        PickerDestination.ShowMenuAtCursor(menu);
                        return false;
                    }
                }
                OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, captureDetails.Title, attachmentName);
            }
            surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
            surface.Modified = false;

            // Don't know how to handle a cancel in the email

            return true;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:58,代码来源:EmailDestination.cs

示例14: ExportCapture

 public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
 {
     using (Image image = surface.GetImageForExport()) {
         if (page != null) {
             try {
                 OneNoteExporter.ExportToPage((Bitmap)image, page);
             } catch (Exception ex) {
                 LOG.Error(ex);
             }
         }
     }
     return true;
 }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:13,代码来源:OneNoteDestination.cs

示例15: ExportCapture

        public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            PrinterSettings printerSettings = null;
            using (Image image = surface.GetImageForExport()) {
                if (!string.IsNullOrEmpty(printerName)) {
                    printerSettings = new PrintHelper(image, captureDetails).PrintTo(printerName);
                } else if (!manuallyInitiated) {
                    PrinterSettings settings = new PrinterSettings();
                    printerSettings = new PrintHelper(image, captureDetails).PrintTo(settings.PrinterName);
                } else {
                    printerSettings = new PrintHelper(image, captureDetails).PrintWithDialog();
                }
                if (printerSettings != null) {
                    surface.Modified = false;
                    surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.editor_senttoprinter, printerSettings.PrinterName));
                }
            }

            return printerSettings != null;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:20,代码来源:PrinterDestination.cs


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