//
// 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
{
// Change picture contrast.
public class PicEffContrast
{
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);
// Decrease picture contrast:
var picture = doc.Body.AddParagraph().AddRun().AddPicture(bytes, @"image/jpeg", 450, 300);
picture.ImageData.Contrast = -0.5f;
doc.Body.AddParagraph($"Picture contrast is {picture.ImageData.Contrast}", captionStyle);
// Done:
return doc;
}
}
}