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:
RKrom 2012-12-11 14:36:20 +00:00
commit 5541e2e1c7
27 changed files with 191 additions and 290 deletions

View file

@ -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;

View file

@ -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);