Class PdfColorMask
Represents the color mask for Bitmap images.
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfColorMask : PdfMask
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
Declaration
public PdfColorMask(PdfColor startColor, PdfColor endColor)
Parameters
Type | Name | Description |
---|---|---|
PdfColor | startColor | The start color of the color mask. |
PdfColor | endColor | 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.
Declaration
public PdfColor EndColor { get; set; }
Property Value
Type | Description |
---|---|
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.
Declaration
public PdfColor StartColor { get; set; }
Property Value
Type | Description |
---|---|
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)