PixMap ToGrayscale Function. Converts the image to grayscale. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

Converts the image to grayscale.

 

   
Syntax  

[C#]
void ToGrayscale()

[Visual Basic]
Sub ToGrayscale()

 

   

Params
 
Name Description
none  

 

   

Notes
 

This allows you to convert an image to grayscale. It can be useful for preparing soft masks.

This function is a convenience method for this common operation. A practically identical effect can be achieved using the Recolor method followed by Compress.

 

   

Example
 

Here we add an image in its natural color space and then, at a position down and to the right, converted to grayscale.

[C#]
Doc theDoc = new Doc();
theDoc.Rect.Pin = XRect.Corner.TopLeft;
theDoc.Rect.Magnify(0.5, 0.5);
string thePath = Server.MapPath("../mypics/mypic.tif");
theDoc.AddImageFile(thePath, 1);
theDoc.Rect.Move(theDoc.Rect.Width, -theDoc.Rect.Height);
int i = theDoc.AddImageFile(thePath, 1);
ImageLayer im = (ImageLayer)theDoc.ObjectSoup[i];
im.PixMap.ToGrayscale();
theDoc.Save(Server.MapPath("pixmaptograyscale.pdf"));
theDoc.Clear();

[Visual Basic]
Dim theDoc As Doc = New Doc()
theDoc.Rect.Pin = XRect.Corner.TopLeft
theDoc.Rect.Magnify(0.5, 0.5)
Dim thePath As String = Server.MapPath("../mypics/mypic.tif")
theDoc.AddImageFile(thePath, 1)
theDoc.Rect.Move(theDoc.Rect.Width, -theDoc.Rect.Height)
Dim i As Integer = theDoc.AddImageFile(thePath,1)
Dim im As ImageLayer = CType(theDoc.ObjectSoup(i), ImageLayer)
im.PixMap.ToGrayscale()
theDoc.Save(Server.MapPath("pixmaptograyscale.pdf"))
theDoc.Clear()


pixmaptograyscale.pdf