# gd_interpolation.c

Summary

gd_interpolation.c |
gdImageScale | Scale an image
gdImageRotateInterpolated | Rotate an image
Affine Transformation |
gdTransformAffineGetImage | Applies an affine transformation to a region and return an image containing the complete transformation.
getPixelRgbInterpolated | get the index of the image’s colors
gdTransformAffineCopy | Applies an affine transformation to a region and copy the result in a destination to the given position.
gdTransformAffineBoundingBox | Returns the bounding box of an affine transformation applied to a rectangular area gdRect
Interpolation Method |
gdImageSetInterpolationMethod | Set the interpolation method for subsequent operations
gdImageGetInterpolationMethod | Get the current interpolation method

### gdImageScale

> gdImagePtr gdImageScale( | const | gdImagePtr | src,
> | const unsigned | int | new_width,
> | const unsigned | int | new_height | )

Scale an image

Creates a new image, scaled to the requested size using the current gdInterpolationMethod.

Note that GD_WEIGHTED4 is not yet supported by this function.

#### Parameters

src | The source image.
new_width | The new width.
new_height | The new height.

#### Returns

The scaled image on success, NULL on failure.

#### See also

- gdImageCopyResized
- gdImageCopyResampled

### gdImageRotateInterpolated

> gdImagePtr gdImageRotateInterpolated( | const | gdImagePtr | src,
> | const | float | angle,
> |  | int | bgcolor | )

Rotate an image

Creates a new image, counter-clockwise rotated by the requested angle using the current gdInterpolationMethod. Non-square angles will add a border with bgcolor.

#### Parameters

src | The source image.
angle | The angle in degrees.
bgcolor | The color to fill the added background with.

#### Returns

The rotated image on success, NULL on failure.

#### See also

- gdImageCopyRotated

### Affine Transformation

### gdTransformAffineGetImage

> int gdTransformAffineGetImage( |  | gdImagePtr | * | dst,
> | const | gdImagePtr |  | src,
> |  | gdRectPtr |  | src_area,
> | const | double |  | affine[6] | )

Applies an affine transformation to a region and return an image containing the complete transformation.

#### Parameters

dst | Pointer to a gdImagePtr to store the created image, NULL when the creation or the transformation failed
src | Source image
src_area | rectangle defining the source region to transform
dstY | Y position in the destination image
affine | The desired affine transformation

#### Returns

GD_TRUE if the affine is rectilinear or GD_FALSE

### getPixelRgbInterpolated

> static int getPixelRgbInterpolated( |  | gdImagePtr | im,
> | const | int | tcolor | )

get the index of the image’s colors

#### Parameters

im | Image to draw the transformed image
tcolor | TrueColor

#### Return

index of colors

### gdTransformAffineCopy

> int gdTransformAffineCopy( |  | gdImagePtr | dst,
> |  | int | dst_x,
> |  | int | dst_y,
> | const | gdImagePtr | src,
> |  | gdRectPtr | src_region,
> | const | double | affine[6] | )

Applies an affine transformation to a region and copy the result in a destination to the given position.

#### Parameters

dst | Image to draw the transformed image
src | Source image
dstX | X position in the destination image
dstY | Y position in the destination image
src_area | Rectangular region to rotate in the src image

#### Returns

GD_TRUE on success or GD_FALSE on failure

### gdTransformAffineBoundingBox

> int gdTransformAffineBoundingBox( |  | gdRectPtr | src,
> | const | double | affine[6],
> |  | gdRectPtr | bbox | )

Returns the bounding box of an affine transformation applied to a rectangular area gdRect

#### Parameters

src | Rectangular source area for the affine transformation
affine | the affine transformation
bbox | the resulting bounding box

#### Returns

GD_TRUE if the affine is rectilinear or GD_FALSE

### Interpolation Method

### gdImageSetInterpolationMethod

> int gdImageSetInterpolationMethod( | gdImagePtr | im,
> | gdInterpolationMethod | id | )

Set the interpolation method for subsequent operations

#### Parameters

im | The image.
id | The interpolation method.

#### Returns

Non-zero on success, zero on failure.

#### See also

- gdInterpolationMethod
- gdImageGetInterpolationMethod

### gdImageGetInterpolationMethod

> gdInterpolationMethod gdImageGetInterpolationMethod( | gdImagePtr | im | )

Get the current interpolation method

This is here so that the value can be read via a language or VM with an FFI but no (portable) way to extract the value from the struct.

#### Parameters

im | The image.

#### Returns

The current interpolation method.

#### See also

- gdInterpolationMethod
- gdImageSetInterpolationMethod

> gdImagePtr gdImageScale( | const | gdImagePtr | src,
> | const unsigned | int | new_width,
> | const unsigned | int | new_height | )

Scale an image

> gdImagePtr gdImageRotateInterpolated( | const | gdImagePtr | src,
> | const | float | angle,
> |  | int | bgcolor | )

Rotate an image

> int gdTransformAffineGetImage( |  | gdImagePtr | * | dst,
> | const | gdImagePtr |  | src,
> |  | gdRectPtr |  | src_area,
> | const | double |  | affine[6] | )

Applies an affine transformation to a region and return an image containing the complete transformation.

> static int getPixelRgbInterpolated( |  | gdImagePtr | im,
> | const | int | tcolor | )

get the index of the image’s colors

> int gdTransformAffineCopy( |  | gdImagePtr | dst,
> |  | int | dst_x,
> |  | int | dst_y,
> | const | gdImagePtr | src,
> |  | gdRectPtr | src_region,
> | const | double | affine[6] | )

Applies an affine transformation to a region and copy the result in a destination to the given position.

> int gdTransformAffineBoundingBox( |  | gdRectPtr | src,
> | const | double | affine[6],
> |  | gdRectPtr | bbox | )

Returns the bounding box of an affine transformation applied to a rectangular area gdRect
A rectangle in the coordinate space of the image

> int gdImageSetInterpolationMethod( | gdImagePtr | im,
> | gdInterpolationMethod | id | )

Set the interpolation method for subsequent operations

> gdInterpolationMethod gdImageGetInterpolationMethod( | gdImagePtr | im | )

Get the current interpolation method

> void gdImageCopyResized ( | gdImagePtr | dst,
> | gdImagePtr | src,
> | int | dstX,
> | int | dstY,
> | int | srcX,
> | int | srcY,
> | int | dstW,
> | int | dstH,
> | int | srcW,
> | int | srcH | )

Copy a resized area from an image to another image

> void gdImageCopyResampled ( | gdImagePtr | dst,
> | gdImagePtr | src,
> | int | dstX,
> | int | dstY,
> | int | srcX,
> | int | srcY,
> | int | dstW,
> | int | dstH,
> | int | srcW,
> | int | srcH | )

Copy a resampled area from an image to another image

> void gdImageCopyRotated ( | gdImagePtr | dst,
> | gdImagePtr | src,
> | double | dstX,
> | double | dstY,
> | int | srcX,
> | int | srcY,
> | int | srcWidth,
> | int | srcHeight,
> | int | angle | )

Copy a rotated area from an image to another image
Close