Table of Contents

Class PdfColorMask

Namespace
Syncfusion.Pdf.Graphics
Assembly
Syncfusion.Pdf.Portable.dll

Represents the color mask for Bitmap images.

public class PdfColorMask : PdfMask
Inheritance
PdfColorMask
Inherited Members

Examples

//Create a new PDF document.
 PdfDocument doc = new PdfDocument();
 //Add a page to the document.
 PdfPage page = doc.Pages.Add();
 //Create PDF graphics for the page
 PdfGraphics graphics = page.Graphics;
 //Load image from file
 Image picture = Image.FromFile("Autumn Leaves.jpg");
 //Load the image from the Image object
 PdfBitmap image = new PdfBitmap(picture);
 //Create a color mask
 PdfColorMask mask = new PdfColorMask(new PdfColor(Color.Red), new PdfColor(Color.Aqua));
 //Apply a mask to the image
 image.Mask = mask;
 //Draw the image
 graphics.DrawImage(image, 0, 0);
 //Save the document.
 doc.Save("Output.pdf");
 //Close the document.
 doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Load image from file
Dim picture As Image = Image.FromFile("Autumn Leaves.jpg")
'Load the image from the Image object
Dim image As New PdfBitmap(picture)
'Create a color mask
Dim mask As New PdfColorMask(New PdfColor(Color.Red), New PdfColor(Color.Aqua))
'Apply a mask to the image
image.Mask = mask
'Draw the image
graphics.DrawImage(image, 0, 0)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Constructors

PdfColorMask(PdfColor, PdfColor)

Initializes a new instance of the PdfColorMask class with the specified start and end color

public PdfColorMask(PdfColor startColor, PdfColor endColor)

Parameters

startColor PdfColor

The start color of the color mask.

endColor PdfColor

The end color of the color mask.

Examples

//Create a new PDF document.///PdfDocument doc = new PdfDocument();
 //Add a page to the document.
 PdfPage page = doc.Pages.Add();
 //Create PDF graphics for the page
 PdfGraphics graphics = page.Graphics;
 //Load image from file
 Image picture = Image.FromFile("Autumn Leaves.jpg");
 //Load the image from the Image object
 PdfBitmap image = new PdfBitmap(picture);
 //Create a color mask
 PdfColorMask mask = new PdfColorMask(new PdfColor(Color.Red), new PdfColor(Color.Aqua));
 //Apply a mask to the image
 image.Mask = mask;
 //Draw the image
 graphics.DrawImage(image, 0, 0);
 //Save the document.
 doc.Save("Output.pdf");
 //Close the document.
 doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Load image from file
Dim picture As Image = Image.FromFile("Autumn Leaves.jpg")
'Load the image from the Image object
Dim image As New PdfBitmap(picture)
'Create a color mask
Dim mask As New PdfColorMask(New PdfColor(Color.Red), New PdfColor(Color.Aqua))
'Apply a mask to the image
image.Mask = mask
'Draw the image
graphics.DrawImage(image, 0, 0)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Properties

EndColor

Gets or sets the end color of the mask.

public PdfColor EndColor { get; set; }

Property Value

PdfColor

The PdfColor which represents the ending color of the color mask.

Examples

//Create a new PDF document.///PdfDocument doc = new PdfDocument();
 //Add a page to the document.
 PdfPage page = doc.Pages.Add();
 //Create PDF graphics for the page
 PdfGraphics graphics = page.Graphics;
 //Load image from file
 Image picture = Image.FromFile("Autumn Leaves.jpg");
 //Load the image from the Image object
 PdfBitmap image = new PdfBitmap(picture);
 //Create a color mask
 PdfColorMask mask = new PdfColorMask(new PdfColor(Color.Red), new PdfColor(Color.Aqua));
 //Set start color.
 mask.StartColor = new PdfColor(Color.Green);
 //Set end color.
 mask.EndColor = new PdfColor(Color.Red);
 //Apply a mask to the image
 image.Mask = mask;
 //Draw the image
 graphics.DrawImage(image, 0, 0);
 //Save the document.
 doc.Save("Output.pdf");
 //Close the document.
 doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Load image from file
Dim picture As Image = Image.FromFile("Autumn Leaves.jpg")
'Load the image from the Image object
Dim image As New PdfBitmap(picture)
'Create a color mask
Dim mask As New PdfColorMask(New PdfColor(Color.Red), New PdfColor(Color.Aqua))
'Set start color.
mask.StartColor = New PdfColor(Color.Green)
'Set end color.
mask.EndColor = New PdfColor(Color.Red)
'Apply a mask to the image
image.Mask = mask
'Draw the image
graphics.DrawImage(image, 0, 0)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

StartColor

Gets or sets the start color of the mask.

public PdfColor StartColor { get; set; }

Property Value

PdfColor

The PdfColor which represents the starting color of the color mask.

Examples

//Create a new PDF document.///PdfDocument doc = new PdfDocument();
 //Add a page to the document.
 PdfPage page = doc.Pages.Add();
 //Create PDF graphics for the page
 PdfGraphics graphics = page.Graphics;
 //Load image from file
 Image picture = Image.FromFile("Autumn Leaves.jpg");
 //Load the image from the Image object
 PdfBitmap image = new PdfBitmap(picture);
 //Create a color mask
 PdfColorMask mask = new PdfColorMask(new PdfColor(Color.Red), new PdfColor(Color.Aqua));
 //Set start color.
 mask.StartColor = new PdfColor(Color.Green);
 //Set end color.
 mask.EndColor = new PdfColor(Color.Red);
 //Apply a mask to the image
 image.Mask = mask;
 //Draw the image
 graphics.DrawImage(image, 0, 0);
 //Save the document.
 doc.Save("Output.pdf");
 //Close the document.
 doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Load image from file
Dim picture As Image = Image.FromFile("Autumn Leaves.jpg")
'Load the image from the Image object
Dim image As New PdfBitmap(picture)
'Create a color mask
Dim mask As New PdfColorMask(New PdfColor(Color.Red), New PdfColor(Color.Aqua))
'Set start color.
mask.StartColor = New PdfColor(Color.Green)
'Set end color.
mask.EndColor = New PdfColor(Color.Red)
'Apply a mask to the image
image.Mask = mask
'Draw the image
graphics.DrawImage(image, 0, 0)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)