Class: THalftoneDither

Declaration: HalftoneDither.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TMatrixDither

Inherited By:

TEllipticDotHalftone TLineDotHalftone TRoundDotHalftone TSpiralDotHalftone TSquareDotHalftone TTriangleDotHalftone

Purpose:

Halftoning is the process by which grays and colors are simulated by using multiple device pixels to represent a single image pixel. You can see halftoning in action in any newspaper. Look at any picture and you can see that the image is comprised of thousands of tiny dots. This process is called halftoning. THalftoneDither and its derived classes use frequency, angle, and spot function to implement halftone algorithms. Frequency is the number of halftone cells per inch. Angle defines the angle at which the halftone screen is placed over device space. The spot function defines the shape of the halftone dots. THalftoneDither is an abstract base class for implementing halftoning algorithms. Classes deriving from THalftoneDither implement specific spot functions such as an elliptical, line, round, square, or triangle dot function. You can modify the screen angle and frequency on any instance of any class derived from THalftoneDither. However, to create a custom spot function you must derive from THalftoneDither and override GetSpotFunction. THalftoneDither creates this typedef: typedef GCoordinate ( * HalftoneSpotFunc ) ( const TGPoint & uv ) Use this to define your own spot function. A spot function takes in a TGPoint and returns a GCoordinate. When halftoning is taking place, the spot function is called for each halftone pixel. The system passes in a TGPoint representing the location of the halftone pixel in the halftone cell. The spot function returns a GCoordinate for that halftone pixel representing its relative priority to be highlighted. For a round dot function, the center pixel has the highest priority and thus is lit first. As you move from the center of the halftone cell, the priorities decrease, thus producing a round halftone dot. THalftoneDither derives from TMatrixDither. The spot function is converted to a dither matrix for performance reasons.

Instantiation:

Abstract base class; do not allocate.

Deriving Classes:

Developers who want to implement other spot functions must derive from THalftoneDither and override GetSpotFunction.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: THalftoneDither::~THalftoneDither

virtual ~ THalftoneDither ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::GetScreenAngle

GCoordinate GetScreenAngle () const

Interface Category:

API.

Purpose:

Gets the angle of the screen in degrees. The default screen angle is 45 degrees.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the angle of the screen in degrees.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::GetScreenFrequency

GCoordinate GetScreenFrequency () const

Interface Category:

API.

Purpose:

Gets the number of halftone dots per inch. The default screen frequency is 72 dots per inch.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the number of halftone dots per inch.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::IsCenterClustered

virtual bool IsCenterClustered () const

Interface Category:

API.

Purpose:

Determines if the halftone dots are clustered near the center.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns true if the halftone dots are center clustered.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

THalftoneDither's implementation of this member function always returns true. Classes deriving from THalftoneDither should override this function for different behavior.

Member Function: THalftoneDither::CreateDitherMatrix

virtual DitherMatrix * CreateDitherMatrix (GCoordinate horzDPI, GCoordinate vertDPI) const

Interface Category:

API.

Purpose:

Sets up a matrix derived from the angle, frequency, and spot function. This matrix is used to speed up halftoning computations.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the computed dither matrix.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::SetScreenAngle

void SetScreenAngle (GCoordinate a)

Interface Category:

API.

Purpose:

Sets the angle of the halftone screen in degrees. The default screen angle is 45 degrees.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::SetScreenFrequency

void SetScreenFrequency (GCoordinate f)

Interface Category:

API.

Purpose:

Sets the number of halftone dots per inch. The default value is 72 dots per inch.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::operator=

THalftoneDither & operator =(const THalftoneDither & source)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function by using the operator in an assignment statement.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::operator>>=

virtual TStream & operator >>=(TStream &) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::operator<<=

virtual TStream & operator <<= (TStream &)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: THalftoneDither::THalftoneDither

  1. THalftoneDither ()
  2. THalftoneDither (GCoordinate angle, GCoordinate freq)
  3. THalftoneDither (const THalftoneDither &)

Interface Category:

API.

Purpose:

  1. Default constructor. Initializes frequency and angle to their default values of 72 dots per inch and 45 degrees, respectively.
  2. Creates a new THalftoneDither object and initializes the angle and frequency to the specified values.
  3. Copy constructor.

Calling Context:

  1. Called by the stream-in operators.
  2. Call this function directly.
  3. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

THalftoneDither is an abstract base class--all the constructors are protected. Do not instantiate this class.

Member Function: THalftoneDither::GetSpotFunction

virtual HalftoneSpotFunc GetSpotFunction () const

Interface Category:

API.

Purpose:

Gets a pointer to the function that implements the spot function.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a pointer to the spot function.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is a pure virtual function and must be overridden by classes deriving from THalftoneDither.

Member Function: THalftoneDither::TemporaryTypeID

virtual EDitherHintClassID TemporaryTypeID () const

Interface Category:

API.

Purpose:

Used to type identify this class. This is only temporary until the ANSI C++ typeid operator is available.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns an EDitherHintClassID which identifies the dither class for this object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This is a temporary function.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.