XRendering DefaultHalftone Property. Halftone type and options. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

 

Type Default Value Read Only Description
[C#] string

[Visual Basic]
String
  "Spot,30,100,CosineDot" No Halftone type and options.

 

   

Notes
 

Specifies the default halftone type and options.

The default halftone remains in effect until an embedded halftone screen is encountered.

The Type can be:

  • Spot
  • ErrorDiffusion
  • OrderedDither
  • Threshold

If the type is Spot then an angle in degrees, frequency and spot function can also be specified. These should be separated by commas with no extraneous spaces. The spot functions available are:

  • SimpleDot
  • InvertedSimpleDot
  • DoubleDot
  • InvertedDoubleDot
  • CosineDot
  • Double
  • InvertedDouble
  • Line
  • LineX
  • LineY
  • Round
  • Ellipse
  • EllipseA
  • InvertedEllipseA
  • EllipseB
  • EllipseC
  • InvertedEllipseC
  • Square
  • Cross
  • Rhomboid
  • Diamond

If the type is Threshold you should specify a value - for example "'threshold=60". This is used when calculating the value of a black and white pixel. If the grey level l is greater than the threshold the pixel will be black otherwise it will be white.

For full details of how Halftones work you should see the Adobe PDF Specification available from the Adobe web site.

 

   

Example
 

The following example shows the effect that this parameter has on PDF rendering.

[C#]
Doc theDoc = new Doc();
XImage image = new XImage();
image.SetFile(Server.MapPath("../mypics/Shuttle.jpg"));
theDoc.Rect.String = image.Selection.String;
theDoc.AddImage(image);
// Save rendered image as black and white picture using Line spot function
theDoc.Rendering.UseEmbeddedHalftone = false;
theDoc.Rendering.DotsPerInch = 50;
theDoc.Rendering.ColorSpace = XRendering.ColorSpaceType.Gray;
theDoc.Rendering.BitsPerChannel = 1;
theDoc.Rendering.DefaultHalftone = "Spot,30,100,Line";
theDoc.Rendering.Save(Server.MapPath("RenderingHalftoneLine.png"));
// Save rendered image as black and white picture using Diamond spot function
theDoc.Rendering.DefaultHalftone = "Spot,0,100,Diamond";
theDoc.Rendering.Save(Server.MapPath("RenderingHalftoneDiamond.png"));
theDoc.Clear();

[Visual Basic]
Dim theDoc As Doc = New Doc()
Dim image As XImage = New XImage()
image.SetFile(Server.MapPath("../mypics/Shuttle.jpg"))
theDoc.Rect.String = image.Selection.String
theDoc.AddImage(image)
' Save rendered image as black and white picture using Line spot function
theDoc.Rendering.UseEmbeddedHalftone = False
theDoc.Rendering.DotsPerInch = 50
theDoc.Rendering.ColorSpace = XRendering.ColorSpaceType.Gray
theDoc.Rendering.BitsPerChannel = 1
theDoc.Rendering.DefaultHalftone = "Spot,30,100,Line"
theDoc.Rendering.Save(Server.MapPath("RenderingHalftoneLine.png"))
' Save rendered image as black and white picture using Diamond spot function
theDoc.Rendering.DefaultHalftone = "Spot,0,100,Diamond"
theDoc.Rendering.Save(Server.MapPath("RenderingHalftoneDiamond.png"))
theDoc.Clear()


RenderingHalftoneLine.png


RenderingHalftoneDiamond.png