gd_interpolation.c

Summary
gd_interpolation.c
gdImageScaleScale an image
gdImageRotateInterpolatedRotate an image
Affine Transformation
gdTransformAffineGetImageApplies an affine transformation to a region and return an image containing the complete transformation.
gdTransformAffineCopyApplies an affine transformation to a region and copy the result in a destination to the given position.
gdTransformAffineBoundingBoxReturns the bounding box of an affine transformation applied to a rectangular area gdRect
Interpolation Method
gdImageSetInterpolationMethodSet the interpolation method for subsequent operations
gdImageGetInterpolationMethodGet 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

srcThe source image.
new_widthThe new width.
new_heightThe new height.

Returns

The scaled image on success, NULL on failure.

See also

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

srcThe source image.
angleThe angle in degrees.
bgcolorThe color to fill the added background with.

Returns

The rotated image on success, NULL on failure.

See also

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

dstPointer to a gdImagePtr to store the created image, NULL when the creation or the transformation failed
srcSource image
src_arearectangle defining the source region to transform
dstYY position in the destination image
affineThe desired affine transformation

Returns

GD_TRUE if the affine is rectilinear or GD_FALSE

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

dstImage to draw the transformed image
srcSource image
dstXX position in the destination image
dstYY position in the destination image
src_areaRectangular region to rotate in the src image

Returns

GD_TRUE if the affine is rectilinear or GD_FALSE

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

srcRectangular source area for the affine transformation
affinethe affine transformation
bboxthe 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

imThe image.
idThe interpolation method.

Returns

Non-zero on success, zero on failure.

See also

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

imThe image.

Returns

The current interpolation method.

See also

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.
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