//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Word;
namespace DsWordWeb.Demos
{
// Recolor picture.
public class PicEffRecolor
{
public GcWordDocument CreateDocx()
{
var doc = new GcWordDocument();
Util.SetNarrowMargins(doc);
var captionStyle = doc.Styles.Add("CaptionStyle", doc.Styles[BuiltInStyleId.BodyTextFirstIndent2]);
// Read image from a file:
var bytes = File.ReadAllBytes(Path.Combine("Resources", "Images", "wargravepink.jpg"));
// Original picture:
doc.Body.AddParagraph().AddRun().AddPicture(bytes, @"image/jpeg", 450, 300);
doc.Body.AddParagraph("Original picture", captionStyle);
// Recolor picture:
var picture = doc.Body.AddParagraph().AddRun().AddPicture(bytes, @"image/jpeg", 450, 300);
picture.ImageData.Recolor(RecolorType.Sepia);
doc.Body.AddParagraph($"Recolor effect ({RecolorType.Sepia})", captionStyle);
// Done:
return doc;
}
}
}