[]
        
(Showing Draft Content)

Picture Format

GcWord allows you to enhance the look of a picture by customizing the picture formats using EmbeddedImageData and ImageData classes. ImageData class enables you to apply effects, adjust brightness, contrast, sharpness, etc., and change the color to a preset color or a custom color.

Apply Picture Effects

GcWord allows you to enhance your picture by adding picture effects, such as blur, grayscale, tint, duo tone, fill overlay, etc using Effects property of ImageData class.

Refer to the following example code to add grayscale effect to the picture:

// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Read PNG image from a file.
var bytes = File.ReadAllBytes(@"image.png");
            
// Add PNG picture into the document.
var picture = doc.Body.AddParagraph().AddRun().AddPicture(bytes, @"image/png", 300f, 300f);

// Add grayscale to the picture.
picture.ImageData.Effects.AddGrayscale();
            
// Save the Word document.
doc.Save(@"picture-effects.docx");

Original

Grayscale Effect

image

image

Adjust Picture Settings

GcWord allows you to enhance your picture by adjusting the picture settings, such as brightness, contrast, temperature, saturation, and sharpness, using ImageData property of Picture class.

Refer to the following example code to adjust the brightness and contrast of a picture:

// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Read PNG image from a file.
var bytes = File.ReadAllBytes(@"image.png");

// Add PNG picture into the document.
var picture = doc.Body.AddParagraph().AddRun().AddPicture(bytes, @"image/png", 300f, 300f);

// Increase the picture brightness.
picture.ImageData.Brightness = 0.5f;

// Decrease the picture contrast.
picture.ImageData.Contrast = -0.5f;

// Save the Word document.
doc.Save(@"picture-settings.docx");

Original

Brightness and Contrast Adjusted

image

image

Change Picture Color

GcWord allows you to enhance your picture by adjusting the picture color to a preset color or desired colors using Recolor method of ImageData class and AddColorChange method of ImageEffectList class.

Refer to the following example code to adjust the picture color to a preset color:

// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Read PNG image from a file.
var bytes = File.ReadAllBytes(@"image.png");

// Add PNG picture into the document.
var picture = doc.Body.AddParagraph().AddRun().AddPicture(bytes, @"image/png", 300f, 300f);

// Recolor the picture to grayscale.
picture.ImageData.Recolor(RecolorType.Accent1Light);

// Save the Word document.
doc.Save(@"recolor-preset.docx");

Original

Preset Color: Accent1Light

image

image

Refer to the following example code to adjust the picture color to the desired color:

// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Read JPEG image from a file.
var bytes = File.ReadAllBytes(@"image.png");

// Add JPEG picture into the document.
var picture = doc.Body.AddParagraph().AddRun().AddPicture(bytes, @"image/png", 300f, 300f);

// Change blue to green color in the picture.
picture.ImageData.Effects.AddColorChange(new UserColor(Color.FromArgb(15,17,19)), new UserColor(Color.Green));

// Save the Word document.
doc.Save(@"recolor-desired-color.docx");

Original

Picture Color Adjusted

image

image

Set Picture Color Transparency

GcWord allows you to set picture color transparency using SetColorTransparent method of ImageData class.

Refer to the following example code to set the black color to transparent:

// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Read PNG image from a file.
var bytes = File.ReadAllBytes(@"image.png");

// Add PNG picture into the document.
var picture = doc.Body.AddParagraph().AddRun().AddPicture(bytes, @"image/png", 300f, 300f);

// Set black color transparent in the picture.
picture.ImageData.SetColorTransparent(new UserColor(Color.FromArgb(15, 17, 19)));

// Save the Word document.
doc.Save(@"set-transparent-color.docx");

Original

Black Color- Transparent

image

image

Limitations

GcWord does not support picture effects in exporting to PDF and images at this time.