This set of unit containt differents addons to GR32 more orless usefull, tested with GR32 version 1.8beta.
The contents of theses files are subject to the Mozilla Public License Version 1.1
GR32_MathAddons.pasThis unit define some procedures and functions specially axed on Single float arithmetic. This include some trigonometric functions (such asTan , ArcTan , ArcCos or Modulo functions) plus some basic mathematical functions (Power , Mean , Min , Max ...) and some other function (such as Convex who can be used to tell if a polygon is convex or not (usefull for the TProjectiveTransformation )).
GR32_TransformsEx.pas and GR32_TransformsWarp.pasTheses unit define some new transformations, most of then are taken from the Paul Bourke article : Image warping / distortion. See his web page for details, C implementation and screenshoot. Every distortions are based on a generic transformationTCustomWarpTransformation .
this one transform the coordinate in an normal system, then X and Y are
Single form -1 to 1, the final transformation can apply any function to
the coordinates without state of the real Source and Dest rects.
GR32_TransformsEx.pas define a spacial transformation, TSphereTransformation ,
witch perform an sheprical projection of a planar image. The resulting
sphere projection can be moved, scalled and rotated (with Longitude and
Latitude coordinates system).
PerfsTransforms.zip is an modified version of the GR32 sample application TransformEx with this Transformations illustrated. (here is the Exe only archive).
GR32_RasterizerEx.pasThis unit define a really simple rasterizer class. It draw the bitmap in a "boxed" way, instead of define a color for each pixel of the image, a color value is caculated for a square of pixel (a property of the Rasterizer). The result is a weird image really pixelixed, but the resulting bitmap can be calculated more quickly than the whole image. This can be usefull, if each pixel is the result of a complex transformation, to preview the final image. This rasterizer has been used in the above Transforms demo to accelerate the rendering during mouse dragging operations on the spherical projection.GR32_Convolution.pasThis unit is a fused version of the Antti Lukats MMX implementation of kernel 3x3 convolution and the so called PixelPtr implementation of Patrick Quinn. It use 3 PixelPtr (one per line) and MMX operations when available, if there is not MMX or when the use of MMX operation is not profitable it use the PixelPtr implementation. i.e. MMX does not propose a divide operator, so when the kernel has a factor (i.e. the matrix is not normalized) and when this factor is not a power of 2, it doas NOT use MMX operations at all, because switching from MMX to integer arithmetic, apply 4 div and switch back to MMX, is slower than doing the whole stuff with standart operations. By the way, kernels normalmized or with a power of 2 normalisation factor represent most of the kernels... If you are using user's defined kernels you should (if you can) adjust the normalisation factor to be executed with an MMX version of the function. The following application is a benchmark between the diferents implementation. Applied to an image 1600x1200, with a Pentium 4 :
|