PixMap SetChromakey Function. Sets a chromakey transparent color for this image. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

Sets a chromakey transparent color for this image.

 

   
Syntax  

[C#]
void SetChromakey(string chromakey)

[Visual Basic]
Sub SetChromakey(chromakey As String)

 

   

Params
 
Name Description
chromakey A chromakey string to assign to this image.

 

   

Notes
 

This allows you to assign a transparent color or color range to the image.

You need to specify two values for each component of the color. For a particular pixel, if all the components of the color fall within the specified ranges, then the pixel will not be displayed.

For example, to make pure white elements of an RGB transparent you might specify,

doc.SetChromakey("255 255 255 255 255 255")

If you wanted to include colors which were off-white you might use,

doc.SetChromakey("250 255 250 255 250 255")

This function is equivalent to setting the PixMap "/Mask" entry to an array of color values.

 

   

Example
 

Here we add an image over the top of a green background. We use a chromakey to make black and near-black colors transparent.

[C#]
Doc theDoc = new Doc();
theDoc.Rect.Inset(20, 20);
theDoc.Color.String = "0 255 0";
theDoc.FillRect();
string thePath = Server.MapPath("../mypics/mypic.tif");
int i = theDoc.AddImageFile(thePath, 1);
ImageLayer im = (ImageLayer)theDoc.ObjectSoup[i];
im.PixMap.SetChromakey("0 50 0 50 0 50");
theDoc.Save(Server.MapPath("pixmapsetchromakey.pdf"));
theDoc.Clear();

[Visual Basic]
Dim theDoc As Doc = New Doc()
theDoc.Rect.Inset(20, 20)
theDoc.Color.String = "0 255 0"
theDoc.FillRect()
Dim thePath As String = Server.MapPath("../mypics/mypic.tif")
Dim i As Integer = theDoc.AddImageFile(thePath,1)
Dim im As ImageLayer = CType(theDoc.ObjectSoup(i), ImageLayer)
im.PixMap.SetChromakey("0 50 0 50 0 50")
theDoc.Save(Server.MapPath("pixmapsetchromakey.pdf"))
theDoc.Clear()


pixmapsetchromakey.pdf