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 currently supports the transformation of RGB images to grayscale. It does not support the conversion of images in other color spaces.

 

   

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 = (int)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