---
name: "transform"
section: "3x"
platform: "linux"
package: "libafterimage-dev"
version: "2.2.12-18"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/transform/3x"
---

# transform(3x)

transformations available for ASImages libAfterImage/transform.h

## NAME

**transform** - transformations available for ASImages libAfterImage/transform.h

## NAMEtransform

## SYNOPSIS

Defines transformations that could be performed on ASImage.

## DESCRIPTION

Transformations can be performed with different degree of quality. Internal engine uses 24.8 bits per channel per pixel. As the result there are no precision loss, while performing complex calculations. Error diffusion algorithms could be used to transform it back into 8 bit without quality loss.

Any Transformation could be performed with the result written directly into XImage, so that it could be displayed faster.

Complex interpolation algorithms are used to perform scaling operations, thus yielding very good quality. All the transformations are performed in integer math, with the result of greater speeds. Optional MMX inline assembly has been incorporated into some procedures, and allows one to achieve considerably better performance on compatible CPUs.

## SEE ALSO

 Transformations :\
          scale\_asimage(), tile\_asimage(), merge\_layers(), \
             make\_gradient(), flip\_asimage(), mirror\_asimage(), \
             pad\_asimage(), blur\_asimage\_gauss(), fill\_asimage(), \
             adjust\_asimage\_hsv()

 Other libAfterImage modules :\
          ascmap.h asfont.h asimage.h asvisual.h blender.h export.h\
          import.h transform.h ximage.h

## AUTHOR

Sasha Vasko \<sasha at aftercode dot net\> libAfterImage/transform/scale\_asimage()

## NAMEscale\_asimage()

\- scales source ASImage into new image of requested dimensions.

## SYNOPSIS

ASImage \*scale\_asimage( struct ASVisual \*asv,\
                         ASImage \*src,\
                         unsigned int to\_width,\
                         unsigned int to\_height,\
                         ASAltImFormats out\_format,\
                         unsigned int compression\_out, int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- src

  \- source ASImage

- to\_width

  \- desired width of the resulting image

- to\_height

  \- desired height of the resulting image

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out-

  compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure.

## DESCRIPTION

If size has to be reduced - then several neighboring pixels will be  averaged into single pixel. If size has to be increased then new  pixels will be interpolated based on values of four neighboring pixels.

## EXAMPLE

ASScale libAfterImage/transform/tile\_asimage()

## NAMEtile\_asimage()

\- tiles/crops ASImage to desired size, while optionally tinting it at the same time.

## SYNOPSIS

ASImage \*tile\_asimage ( struct ASVisual \*asv,\
                         ASImage \*src,\
                         int offset\_x,\
                         int offset\_y,\
                         unsigned int to\_width,\
                         unsigned int to\_height,\
                         ARGB32 tint,\
                         ASAltImFormats out\_format,\
                         unsigned int compression\_out, int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- src

  \- source ASImage

- offset\_x

  \- left clip margin

- offset\_y

  \- right clip margin

- to\_width

  \- desired width of the resulting image

- to\_height

  \- desired height of the resulting image

- tint

  \- ARGB32 value describing tinting color.

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out-

  compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure.

## DESCRIPTION

Offset\_x and offset\_y define origin on source image from which tiling will start. If offset\_x or offset\_y is outside of the image boundaries, then it will be reduced by whole number of image sizes to fit inside the image. At the time of tiling image will be tinted unless tint == 0.

## EXAMPLE

ASTile libAfterImage/transform/merge\_layers()

## NAMEmerge\_layers()

## SYNOPSIS

ASImage \*merge\_layers  ( struct ASVisual \*asv,\
                          ASImageLayer \*layers, int count,\
                          unsigned int dst\_width,\
                          unsigned int dst\_height,\
                          ASAltImFormats out\_format,\
                          unsigned int compression\_out, int quality);

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- layers

  \- array of ASImageLayer structures that will be rendered one on top of another. First element corresponds to the bottommost layer.

- dst\_width

  \- desired width of the resulting image

- dst\_height

  \- desired height of the resulting image

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out

  \- compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure.

## DESCRIPTION

merge\_layers() will create new ASImage of requested size. It will then go through all the layers, and fill image with composition. Bottommost layer will be used unchanged and above layers will be superimposed on it, using algorithm specified in ASImageLayer structure of the overlaying layer. Layers may have smaller size then destination image, and maybe placed in arbitrary locations. Each layer will be padded to fit width of the destination image with all 0 effectively making it transparent. libAfterImage/transform/make\_gradient()

## NAMEmake\_gradient()

\- renders linear gradient into new ASImage

## SYNOPSIS

ASImage \*make\_gradient ( struct ASVisual \*asv,\
                          struct ASGradient \*grad,\
                          unsigned int width,\
                          unsigned int height,\
                          ASFlagType filter,\
                          ASAltImFormats out\_format,\
                          unsigned int compression\_out, int quality);

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- grad

  \- ASGradient structure defining how gradient should be drawn

- width

  \- desired width of the resulting image

- height

  \- desired height of the resulting image

- filter

  \- only channels corresponding to set bits will be rendered.

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out-

  compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure.

## DESCRIPTION

make\_gradient() will create new image of requested size and it will fill it with gradient, described in structure pointed to by grad. Different dithering techniques will be applied to produce nicer looking gradients. libAfterImage/transform/flip\_asimage()

## NAMEflip\_asimage()

\- rotates ASImage in 90 degree increments

## SYNOPSIS

ASImage \*flip\_asimage ( struct ASVisual \*asv,\
                         ASImage \*src,\
                         int offset\_x, int offset\_y,\
                         unsigned int to\_width,\
                         unsigned int to\_height,\
                         int flip, ASAltImFormats out\_format,\
                         unsigned int compression\_out, int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- src

  \- source ASImage

- offset\_x

  \- left clip margin

- offset\_y

  \- right clip margin

- to\_width

  \- desired width of the resulting image

- to\_height

  \- desired height of the resulting image

- flip

  \- flip flags determining degree of rotation.

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out

  \- compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure.

## DESCRIPTION

flip\_asimage() will create new image of requested size, it will then tile source image based on offset\_x, offset\_y, and destination size, and it will rotate it then based on flip value. Three rotation angles supported 90, 180 and 270 degrees. libAfterImage/transform/mirror\_asimage()

## NAMEmirror\_asimage()

## SYNOPSIS

ASImage \*mirror\_asimage ( struct ASVisual \*asv,\
                           ASImage \*src,\
                           int offset\_x, int offset\_y,\
                           unsigned int to\_width,\
                           unsigned int to\_height,\
                           Bool vertical, ASAltImFormats out\_format,\
                           unsigned int compression\_out, int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- src

  \- source ASImage

- offset\_x

  \- left clip margin

- offset\_y

  \- right clip margin

- to\_width

  \- desired width of the resulting image

- to\_height

  \- desired height of the resulting image

- vertical

  \- mirror in vertical direction.

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out

  \- compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure.

## DESCRIPTION

mirror\_asimage() will create new image of requested size, it will then tile source image based on offset\_x, offset\_y, and destination size, and it will mirror it in vertical or horizontal direction. libAfterImage/transform/pad\_asimage()

## NAMEpad\_asimage()

enlarges ASImage, padding it with specified color on each side in accordance with requested geometry.

## SYNOPSIS

ASImage \*pad\_asimage( ASVisual \*asv, ASImage \*src,\
                      int dst\_x, int dst\_y,\
                      unsigned int to\_width,\
                      unsigned int to\_height,\
                      ARGB32 color,\
                      ASAltImFormats out\_format,\
                      unsigned int compression\_out, int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- src

  \- source ASImage

- dst\_x,

  dst\_y - placement of the source image relative to the origin of destination image

- to\_width

  \- width of the destination image

- to\_height

  \- height of the destination image

- color

  \- ARGB32 color value to pad with.

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out

  \- compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure. libAfterImage/transform/blur\_asimage\_gauss()

## NAMEblur\_asimage\_gauss()

Performs Gaussian blurr of the image ( useful for drop shadows and the likes ).

## SYNOPSIS

ASImage\* blur\_asimage\_gauss( ASVisual\* asv, ASImage\* src,\
                              double horz, double vert,\
                              ASAltImFormats out\_format,\
                              unsigned int compression\_out, \
                                 int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- src

  \- source ASImage

- horz

  \- horizontal radius of the blurr

- vert

  \- vertical radius of the blurr

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out

  \- compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure. libAfterImage/transform/fill\_asimage()

## NAMEfill\_asimage()

\- Fills rectangle within the existing ASImage with specified color.

## SYNOPSIS

Bool fill\_asimage( ASVisual \*asv, ASImage \*im,\
                    int x, int y, int width, int height,\
                    ARGB32 color );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- im

  \- ASImage to fill with the color

- x,

  y - left-top corner of the rectangle to fill.

- width,

  height - size of the rectangle to fill.

- color

  \- ARGB32 color value to fill rectangle with.

## RETURN VALUE

True on success, False on failure. libAfterImage/transform/adjust\_asimage\_hsv()

## NAMEadjust\_asimage\_hsv()

\- adjusts image color properties in HSV colorspace

## SYNOPSIS

ASImage \*adjust\_asimage\_hsv( ASVisual \*asv, ASImage \*src,\
                              int offset\_x, int offset\_y,\
                              unsigned int to\_width,\
                              unsigned int to\_height,\
                              unsigned int affected\_hue,\
                              unsigned int affected\_radius,\
                              int hue\_offset, int saturation\_offset,\
                              int value\_offset,\
                              ASAltImFormats out\_format,\
                              unsigned int compression\_out, int quality);

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- src

  \- ASImage to adjust colors of.

- offset\_x,

  - offset\_y

  \- position on infinite surface tiled with original image, of the left-top corner of the area to be used for new image.

- to\_width,

  - to\_height

  \- size of the area of the original image to be used for new image.

- affected\_hue

  \- hue in degrees in range 0-360. This allows one to limit impact of color adjustment to affect only limited range of hues.

- affected\_radius

  Sets the diapason of the range of affected hues.

- hue\_offset

  \- value by which to change hues in affected range.

- saturation\_offset

  \- value by which to change saturation of the pixels in affected hue range.

- value\_offset

  \- value by which to change Value(brightness) of pixels in affected hue range.

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out-

  compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

returns newly created and encoded ASImage on success, NULL of failure.

## DESCRIPTION

This function will tile original image to specified size with offsets requested, and then it will go though it and adjust hue, saturation and value of those pixels that have specific hue, set by affected\_hue/ affected\_radius parameters. When affected\_radius is greater then 180 entire image will be adjusted. Note that since grayscale colors have no hue - the will not get adjusted. Only saturation and value will be adjusted in gray pixels. Hue is measured as an angle on a 360 degree circle, The following is relationship of hue values to regular color names : red      - 0 yellow   - 60 green    - 120 cyan     - 180 blue     - 240 magenta  - 300 red      - 360

All the hue values in parameters will be adjusted to fall within 0-360 range. libAfterImage/transform/colorize\_asimage\_vector()

## NAMEcolorize\_asimage\_vector()

creates ASImage from double precision indexed image data - useful for scientific visualisation.

## SYNOPSIS

Bool colorize\_asimage\_vector( ASVisual \*asv, ASImage \*im,\
                                  ASVectorPalette \*palette,\
                               ASAltImFormats out\_format,\
                               int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- im

  \- ASImage to update.

- palette

  \- palette to be used in conversion of double precision values into colors.

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- quality

  \- output quality

## RETURN VALUE

True on success, False on failure.

## DESCRIPTION

This function will try to convert double precision indexed image data into actuall color image using palette. Original data should be  attached to ASImage using vector member. Operation is relatively fast  and allows representation of scientific data as color image with  dynamically changing palette. libAfterImage/transform/create\_asimage\_from\_vector()

## NAMEcreate\_asimage\_from\_vector()

\- convenience function allowing one to create new ASImage, set its vector data and colorize it using palette - all in one step.

## SYNOPSIS

ASImage \*create\_asimage\_from\_vector( ASVisual \*asv, double \*vector,\
                                      unsigned int width,\
                                      unsigned int height,\
                                      ASVectorPalette \*palette,\
                                      ASAltImFormats out\_format,\
                                      unsigned int compression,\
                                      int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- vector

  \- data to be attached to new ASImage and used to generate RGB image

- width,

  height - size of the new image.

- palette

  \- palette to be used in conversion of double precision values into colors.

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.

- compression\_out-

  compression level of resulting image in range 0-100.

- quality

  \- output quality

## RETURN VALUE

New ASImage  on success, NULL on failure.

## SEE ALSO

colorize\_asimage\_vector(), create\_asimage(), set\_asimage\_vector() libAfterImage/transform/slice\_asimage2()

## NAMEslice\_asimage2()

\- slice ASImage leaving its corners intact, and scaling the middle part.

## SYNOPSIS

ASImage\* slice\_asimage2( ASVisual \*asv, ASImage \*src,\
             int slice\_x\_start, int slice\_x\_end,\
             int slice\_y\_start, int slice\_y\_end,\
             int to\_width,\
             int to\_height,\
             Bool scaled,\
             ASAltImFormats out\_format,\
             unsigned int compression\_out, int quality );

## INPUTS

- asv

  \- pointer to valid ASVisual structure

- src

  \- source ASImage.

- slice\_x\_start

  \- ending of the left corners

- slice\_x\_end

  \- beginning of the right corners

- slice\_y\_start

  \- ending of the top corners

- slice\_y\_end

  \- beginning of the bottom corners

- to\_width

  \- width of the generated image;

- to\_height

  \- height of the generated image;

- scaled

  \- if True - middle part of the image will be scaled, otherwise - tiled;

- out\_format

  \- optionally describes alternative ASImage format that should be produced as the result - XImage, ARGB32, etc.;

- compression\_out-

  compression level of resulting image in range 0-100;

- quality

  \- output quality.

## RETURN VALUE

New ASImage  on success, NULL on failure.

## SEE ALSO

scale\_asimage(), tile\_asimage()
