TManipulator base class

Parent Previous Next

Inherits from: TBitmappedFigure

TManipulator is the base class for tools that manipulate bitmap pixels to achieve some kind of effect. ImagePainter comes with the following tools based on TManipulator:

TBCSManip (brightness/contrast/saturation tool)
THLSMixer (hue/luminance/saturation tool)

Manipulators behave somewhat different than other tools. They have no real substance of their own, but express themselves through their targets, i.e. the object which is to be manipulated. A target must either be a bitmap object or the Selector When connected to a target, the manipulator takes control of the target bitmap and does the work necessary. When the connection ends, the manipulator is destroyed.

The work of a manipulator is divided into sequences or ‘sessions’. During its lifetime the manipulator maintains a copy of the original target bitmap. Within a session each manipulation uses this copy as the source, meaning that successive manipulations will not affect one another. When the session ends, the target bitmap is updated, so the next session will use the updated bitmap as the base.

A session is initiated with a call to BeginManipulate and ended with a call to EndManipulate.

A manipulator is a solely commanded tool. To run it you must use the ExecuteManipulator method of ImagePainter. Within a session you can call the Remanipulate method to perform successive manipulations. In this way the user can test the result of different settings. CancelManipulate closes the connection and restores the bitmap target to its original state.

A manipulator can only have one target, but one and the same object may be targeted by multiple manipulators. In this case, if one manipulator performs a manipulation, the others are notified that  their target bitmap copy has changed.

For simple administration use The TBitmappedFigure.ResetManipulators and ConfirmManipulators to cancel or accept changes with multiple manipulators on the same target.

Use the OnResetManipulator event handler of ImagPainter to detect when the target bitmap is updated or restored.
The Creating your own tools tutorial contains a full listing of the TRGBMixer tool.

See also
Working with manipulators tutorial
Changing bitmaps manually tutorial