mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 14:03:23 -07:00
Refactoring which replaces the Image in the ImageOutput for an ISurface, this makes it possible to save the Surface to any possible file format and even make it possible to pass some additional information in the OutputSettings. (Except reducing the colors, there are no other settings yet)
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2376 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
e11450f56f
commit
5541e2e1c7
27 changed files with 191 additions and 290 deletions
|
@ -109,15 +109,13 @@ namespace GreenshotOfficePlugin {
|
|||
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
|
||||
using (Image image = surface.GetImageForExport()) {
|
||||
if (page != null) {
|
||||
try {
|
||||
OneNoteExporter.ExportToPage((Bitmap)image, page);
|
||||
exportInformation.ExportMade = true;
|
||||
} catch (Exception ex) {
|
||||
exportInformation.ErrorMessage = ex.Message;
|
||||
LOG.Error(ex);
|
||||
}
|
||||
if (page != null) {
|
||||
try {
|
||||
OneNoteExporter.ExportToPage(surface, page);
|
||||
exportInformation.ExportMade = true;
|
||||
} catch (Exception ex) {
|
||||
exportInformation.ErrorMessage = ex.Message;
|
||||
LOG.Error(ex);
|
||||
}
|
||||
}
|
||||
return exportInformation;
|
||||
|
|
|
@ -43,12 +43,12 @@ namespace Greenshot.Interop.Office {
|
|||
private const string ONENOTE_NAMESPACE_2007 = "http://schemas.microsoft.com/office/onenote/2007/onenote";
|
||||
private const string ONENOTE_NAMESPACE_2010 = "http://schemas.microsoft.com/office/onenote/2010/onenote";
|
||||
|
||||
public static void ExportToPage(Bitmap imageToExport, OneNotePage page) {
|
||||
public static void ExportToPage(ISurface surfaceToUpload, OneNotePage page) {
|
||||
using (MemoryStream pngStream = new MemoryStream()) {
|
||||
OutputSettings pngOutputSettings = new OutputSettings(OutputFormat.png, 100, false);
|
||||
ImageOutput.SaveToStream(imageToExport, pngStream, pngOutputSettings);
|
||||
ImageOutput.SaveToStream(surfaceToUpload, pngStream, pngOutputSettings);
|
||||
string base64String = Convert.ToBase64String(pngStream.GetBuffer());
|
||||
string imageXmlStr = string.Format(XML_IMAGE_CONTENT, base64String, imageToExport.Width, imageToExport.Height);
|
||||
string imageXmlStr = string.Format(XML_IMAGE_CONTENT, base64String, surfaceToUpload.Image.Width, surfaceToUpload.Image.Height);
|
||||
string pageChangesXml = string.Format(XML_OUTLINE, new object[] { imageXmlStr, page.PageID, ONENOTE_NAMESPACE_2010, page.PageName });
|
||||
using (IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance<IOneNoteApplication>()) {
|
||||
LOG.InfoFormat("Sending XML: {0}", pageChangesXml);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue