- Main Page
- Modules
- Classes
- Files

# Transformations

## Functions

bool | CxImage::Rotate (float angle, CxImage *iDst=NULL)
bool | CxImage::Rotate2 (float angle, CxImage *iDst=NULL, InterpolationMethod inMethod=IM_BILINEAR, OverflowMethod ofMethod=OM_BACKGROUND, RGBQUAD *replColor=0, bool const optimizeRightAngles=true, bool const bKeepOriginalSize=false)
bool | CxImage::Rotate180 (CxImage *iDst=NULL)
bool | CxImage::Resample (int32_t newx, int32_t newy, int32_t mode=1, CxImage *iDst=NULL)
bool | CxImage::Resample2 (int32_t newx, int32_t newy, InterpolationMethod const inMethod=IM_BICUBIC2, OverflowMethod const ofMethod=OM_REPEAT, CxImage *const iDst=NULL, bool const disableAveraging=false)
bool | CxImage::DecreaseBpp (uint32_t nbit, bool errordiffusion, RGBQUAD *ppal=0, uint32_t clrimportant=0)
bool | CxImage::Dither (int32_t method=0)
bool | CxImage::Crop (int32_t left, int32_t top, int32_t right, int32_t bottom, CxImage *iDst=NULL)
bool | CxImage::Crop (const RECT &rect, CxImage *iDst=NULL)
bool | CxImage::CropRotatedRectangle (int32_t topx, int32_t topy, int32_t width, int32_t height, float angle, CxImage *iDst=NULL)
bool | CxImage::Skew (float xgain, float ygain, int32_t xpivot=0, int32_t ypivot=0, bool bEnableInterpolation=false)
bool | CxImage::Expand (int32_t left, int32_t top, int32_t right, int32_t bottom, RGBQUAD canvascolor, CxImage *iDst=0)
bool | CxImage::Expand (int32_t newx, int32_t newy, RGBQUAD canvascolor, CxImage *iDst=0)
bool | CxImage::Thumbnail (int32_t newx, int32_t newy, RGBQUAD canvascolor, CxImage *iDst=0)
bool | CxImage::CircleTransform (int32_t type, int32_t rmax=0, float Koeff=1.0f)
bool | CxImage::QIShrink (int32_t newx, int32_t newy, CxImage *const iDst=NULL, bool bChangeBpp=false)

## Detailed Description

## Function Documentation

bool CxImage::CircleTransform | ( | int32_t | type,
|  | int32_t | rmax = `0`,
|  | float | Koeff = `1.0f` |
| ) |  |  | `[inherited]`

Perform circle_based transformations.

Parameters:

  | type | - for different transformations
  - 0 for normal (proturberant) FishEye
  - 1 for reverse (concave) FishEye
  - 2 for Swirle
  - 3 for Cilinder mirror
  - 4 for bathroom
  | rmax | - effect radius. If 0, the whole image is processed
  | Koeff | - only for swirle

Author:
  Arkadiy Olovyannikov ark(at)msun(dot)ru

bool CxImage::Crop | ( | const RECT & | rect,
|  | CxImage * | iDst = `NULL` |
| ) |  |  | `[inherited]`

bool CxImage::Crop | ( | int32_t | left,
|  | int32_t | top,
|  | int32_t | right,
|  | int32_t | bottom,
|  | CxImage * | iDst = `NULL` |
| ) |  |  | `[inherited]`

bool CxImage::CropRotatedRectangle | ( | int32_t | topx,
|  | int32_t | topy,
|  | int32_t | width,
|  | int32_t | height,
|  | float | angle,
|  | CxImage * | iDst = `NULL` |
| ) |  |  | `[inherited]`

CropRotatedRectangle

Parameters:

  | topx,topy | : topmost and leftmost point of the rectangle (topmost, and if there are 2 topmost points, the left one)
  | width | : size of the right hand side of rect, from (topx,topy) roundwalking clockwise
  | height | : size of the left hand side of rect, from (topx,topy) roundwalking clockwise
  | angle | : angle of the right hand side of rect, from (topx,topy)
  | iDst | : pointer to destination image (if 0, this image is modified)

Author:
  [VATI]

bool CxImage::DecreaseBpp | ( | uint32_t | nbit,
|  | bool | errordiffusion,
|  | RGBQUAD * | ppal = `0`,
|  | uint32_t | clrimportant = `0` |
| ) |  |  | `[inherited]`

Reduces the number of bits per pixel to nbit (1, 4 or 8). ppal points to a valid palette for the final image; if not supplied the function will use a standard palette. ppal is not necessary for reduction to 1 bpp.

bool CxImage::Dither | ( | int32_t | method = `0` | ) | `[inherited]`

Converts the image to B&W using the desired method :

- 0 = Floyd-Steinberg
- 1 = Ordered-Dithering (4x4)
- 2 = Burkes
- 3 = Stucki
- 4 = Jarvis-Judice-Ninke
- 5 = Sierra
- 6 = Stevenson-Arce
- 7 = Bayer (4x4 ordered dithering)
- 8 = Bayer (8x8 ordered dithering)
- 9 = Bayer (16x16 ordered dithering)

bool CxImage::Expand | ( | int32_t | newx,
|  | int32_t | newy,
|  | RGBQUAD | canvascolor,
|  | CxImage * | iDst = `0` |
| ) |  |  | `[inherited]`

bool CxImage::Expand | ( | int32_t | left,
|  | int32_t | top,
|  | int32_t | right,
|  | int32_t | bottom,
|  | RGBQUAD | canvascolor,
|  | CxImage * | iDst = `0` |
| ) |  |  | `[inherited]`

Expands the borders.

Parameters:

  | left,top,right,bottom | = additional dimensions, should be greater than 0.
  | canvascolor | = border color. canvascolor.rgbReserved will set the alpha channel (if any) in the border.
  | iDst | = pointer to destination image (if it's 0, this image is modified)

Returns:
  true if everything is ok

Author:
  [Colin Urquhart]; changes [DP]

bool CxImage::QIShrink | ( | int32_t | newx,
|  | int32_t | newy,
|  | CxImage *const | iDst = `NULL`,
|  | bool | bChangeBpp = `false` |
| ) |  |  | `[inherited]`

Faster way to almost properly shrink image. Algorithm produces results comparable with "high resoultion shrink" when resulting image is much smaller (that would be 3 times or more) than original. When resulting image is only slightly smaller, results are closer to nearest pixel. This algorithm works by averaging, but it does not calculate fractions of pixels. It adds whole source pixels to the best destionation. It is not geometrically "correct". It's main advantage over "high" resulution shrink is speed, so it's useful, when speed is most important (preview thumbnails, "map" view, ...). Method is optimized for RGB24 images.

Parameters:

  | newx,newy | - size of destination image (must be smaller than original!)
  | iDst | - pointer to destination image (if it's 0, this image is modified)
  | bChangeBpp | - flag points to change result image bpp (if it's true, this result image bpp = 24 (useful for B/W image thumbnails))

Returns:
  true if everything is ok

Author:
  [bd], 9.2004; changes [Artiom Mirolubov], 1.2005

bool CxImage::Resample | ( | int32_t | newx,
|  | int32_t | newy,
|  | int32_t | mode = `1`,
|  | CxImage * | iDst = `NULL` |
| ) |  |  | `[inherited]`

Resizes the image. mode can be 0 for slow (bilinear) method , 1 for fast (nearest pixel) method, or 2 for accurate (bicubic spline interpolation) method. The function is faster with 24 and 1 bpp images, slow for 4 bpp images and slowest for 8 bpp images.

bool CxImage::Resample2 | ( | int32_t | newx,
|  | int32_t | newy,
|  | InterpolationMethod const | inMethod = `IM_BICUBIC2`,
|  | OverflowMethod const | ofMethod = `OM_REPEAT`,
|  | CxImage *const | iDst = `NULL`,
|  | bool const | disableAveraging = `false` |
| ) |  |  | `[inherited]`

New simpler resample. Adds new interpolation methods and simplifies code (using GetPixelColorInterpolated and GetAreaColorInterpolated). It also (unlike old method) interpolates alpha layer.

Parameters:

  | newx,newy | - size of resampled image
  | inMethod | - interpolation method to use (see comments at GetPixelColorInterpolated) If image size is being reduced, averaging is used instead (or simultaneously with) inMethod.
  | ofMethod | - what to replace outside pixels by (only significant for bordering pixels of enlarged image)
  | iDst | - pointer to destination CxImage or NULL.
  | disableAveraging | - force no averaging when shrinking images (Produces aliasing. You probably just want to leave this off...)

Author:
  ***bd*** 2.2004

bool CxImage::Rotate | ( | float | angle,
|  | CxImage * | iDst = `NULL` |
| ) |  |  | `[inherited]`

bool CxImage::Rotate180 | ( | CxImage * | iDst = `NULL` | ) | `[inherited]`

bool CxImage::Rotate2 | ( | float | angle,
|  | CxImage * | iDst = `NULL`,
|  | InterpolationMethod | inMethod = `IM_BILINEAR`,
|  | OverflowMethod | ofMethod = `OM_BACKGROUND`,
|  | RGBQUAD * | replColor = `0`,
|  | bool const | optimizeRightAngles = `true`,
|  | bool const | bKeepOriginalSize = `false` |
| ) |  |  | `[inherited]`

Rotates image around it's center. Method can use interpolation with paletted images, but does not change pallete, so results vary. (If you have only four colours in a palette, there's not much room for interpolation.)

Parameters:

  | angle | - angle in degrees (positive values rotate clockwise)
  | *iDst | - destination image (if null, this image is changed)
  | inMethod | - interpolation method used (IM_NEAREST_NEIGHBOUR produces aliasing (fast), IM_BILINEAR softens picture a bit (slower) IM_SHARPBICUBIC is slower and produces some halos...)
  | ofMethod | - overflow method (how to choose colour of pixels that have no source)
  | replColor | - replacement colour to use (OM_COLOR, OM_BACKGROUND with no background colour...)
  | optimizeRightAngles | - call faster methods for 90, 180, and 270 degree rotations. Faster methods are called for angles, where error (in location of corner pixels) is less than 0.25 pixels.
  | bKeepOriginalSize | - rotates the image without resizing.

Author:
  ***bd*** 2.2004

bool CxImage::Skew | ( | float | xgain,
|  | float | ygain,
|  | int32_t | xpivot = `0`,
|  | int32_t | ypivot = `0`,
|  | bool | bEnableInterpolation = `false` |
| ) |  |  | `[inherited]`

Parameters:

  | xgain,ygain | : can be from 0 to 1.
  | xpivot,ypivot | : is the center of the transformation.
  | bEnableInterpolation | : if true, enables bilinear interpolation.

Returns:
  true if everything is ok

bool CxImage::Thumbnail | ( | int32_t | newx,
|  | int32_t | newy,
|  | RGBQUAD | canvascolor,
|  | CxImage * | iDst = `0` |
| ) |  |  | `[inherited]`

Resamples the image with the correct aspect ratio, and fills the borders.

Parameters:

  | newx,newy | = thumbnail size.
  | canvascolor | = border color.
  | iDst | = pointer to destination image (if it's 0, this image is modified).

Returns:
  true if everything is ok.

Author:
  [Colin Urquhart]