ChartDirector 6.2 (.NET Edition)
A number of low level ChartDirector graphics primitives using the DrawArea
object involve moving some or all pixels by a fractional offset. For example, rotating an image by 45 degrees (using DrawArea.rotate
) will cause some pixels to rotate to non-integer coordinates.
Consider the simplest operation - shifting the image leftwards using DrawArea.move
. If the image is shifted by an integer number of pixels, it is easy to determine the new image.
How about if the image is shifted by a non-integer number of pixels, such as 1.5 pixels? In this case, the pixel (10, 10) in the new image corresponds to pixel (8.5, 10) in the original image.
In graphics theory, the proper way to estimate non-integer-coordinate pixel is by re-sampling. In simple terms, the non-integer-coordinate pixel is computed using "two dimensional interpolation" from nearby integer-coordinate pixels. The interpolation method is called a "filter".
ChartDirector supports a number of filters denoted by the following predefined constants:
Filtering computes a pixel as the weighted average of nearby pixels. What is meant by "nearby"?
In a linear filter, "nearby" means both the horizontal and vertical distances are less than 1 pixel length from the target pixel. This defines the filtering region of the linear filter. Each pixel can have up to 4 integer-coordinate neighbours. So in a linear filter, each pixel is computed by interpolating from up to 4 neighbouring pixels.
The filtering region of different filters are different. For example, the B-spline filter has a filtering region dimension of 2 pixel distance. Each pixel is computed by interpolating from up to 16 nearby pixels. This is because B-spline, being a cubic polynomial algorithm, requires more points for interpolation.
The filtering region will automatically be extended if the graphics operation involves reducing the image size. It is because the each pixel in the reduced image should corresponding to a larger area in the original image. For example, if an image is resized to 30% of the original in width and height, the filtering region dimension will be increased by a factor of 1 / 0.3 = 3.333.
All ChartDirector API that supports re-sampling also supports an additional blur factor parameter. This parameter can be used to extend or reduce the filtering region. For example, a blur factor of 2.5 will increase the filtering region dimension to 250% of the original.
The effect of increasing the blur factor is to blur the image, making it smoother but less sharp. Reducing the blur factor makes the image sharper but less smooth.
© 2017 Advanced Software Engineering Limited. All rights reserved.