- NAME
- SYNOPSIS
- FUNCTION DESCRIPTIONS
  - MagnifyImage
  - MinifyImage
  - SampleImage
  - ScaleImage
  - ZoomImage

# NAME

zoom - Methods to Resize an Image

# SYNOPSIS

magnified_image= MagnifyImage( image );

Image * MinifyImage( Image `*image` );

Image * SampleImage( const Image *image, const unsigned int columns, const unsigned int rows );

Image * ScaleImage( const Image *image, const unsigned int columns, const unsigned int rows );

Image * ZoomImage( Image *image, const unsigned int columns, const unsigned int rows );

# FUNCTION DESCRIPTIONS

## MagnifyImage

Method MagnifyImage creates a new image that is a integral size greater than an existing one. It allocates the memory necessary for the new Image structure and returns a pointer to the new image.

MagnifyImage scans the reference image to create a magnified image by bilinear interpolation. The magnified image columns and rows become:

      number_columns << 1
      number_rows << 1

The format of the MagnifyImage method is:

> magnified_image=MagnifyImage ( image );

A description of each parameter follows:

magnified_image:

  Method MagnifyImage returns a pointer to the image after magnification. A null image is returned if there is a memory shortage.

image:

  The address of a structure of type Image.

## MinifyImage

Method MinifyImage creates a new image that is a integral size less than an existing one. It allocates the memory necessary for the new Image structure and returns a pointer to the new image.

MinifyImage scans the reference image to create a minified image by computing the weighted average of a 4x4 cell centered at each reference pixel. The target pixel requires two columns and two rows of the reference pixels. Therefore the minified image columns and rows become:

      number_columns/2
      number_rows/2

Weights assume that the importance of neighboring pixels is negately proportional to the square of their distance from the target pixel.

The scan only processes pixels that have a full set of neighbors. Pixels in the top, bottom, left, and right pairs of rows and columns are omitted from the scan.

The format of the MinifyImage method is:

> Image *MinifyImage ( Image *image );

A description of each parameter follows:

minified_image:

  Method MinifyImage returns a pointer to the image after reducing. A null image is returned if there is a memory shortage or if the image size is less than IconSize*2.

image:

  The address of a structure of type Image.

## SampleImage

Method SampleImage creates a new image that is a scaled size of an existing one using pixel sampling. It allocates the memory necessary for the new Image structure and returns a pointer to the new image.

The format of the SampleImage method is:

> Image *SampleImage ( const Image *image, const unsigned int columns, const unsigned int rows );

A description of each parameter follows:

sampled_image:

  Method SampleImage returns a pointer to the image after scaling. A null image is returned if there is a memory shortage.

image:

  The address of a structure of type Image.

columns:

  An integer that specifies the number of columns in the sampled image.

rows:

  An integer that specifies the number of rows in the sampled image.

## ScaleImage

Method ScaleImage creates a new image that is a scaled size of an existing one. It allocates the memory necessary for the new Image structure and returns a pointer to the new image. To scale a scanline from x pixels to y pixels, each new pixel represents x/y old pixels. To read x/y pixels, read (x/y rounded up) pixels but only count the required fraction of the last old pixel read in your new pixel. The remainder of the old pixel will be counted in the next new pixel.

The scaling algorithm was suggested by rjohnson@shell.com and is adapted from `pnmscale(1)` of PBMPLUS by Jef Poskanzer.

The format of the ScaleImage method is:

> Image *ScaleImage ( const Image *image, const unsigned int columns, const unsigned int rows );

A description of each parameter follows:

scaled_image:

  Method ScaleImage returns a pointer to the image after scaling. A null image is returned if there is a memory shortage.

image:

  The address of a structure of type Image.

columns:

  An integer that specifies the number of columns in the scaled image.

rows:

  An integer that specifies the number of rows in the scaled image.

## ZoomImage

Method ZoomImage creates a new image that is a scaled size of an existing one. It allocates the memory necessary for the new Image structure and returns a pointer to the new image. The Point filter gives fast pixel replication, Triangle is equivalent to bi-linear interpolation, and Mitchel giver slower, very high-quality results. See Graphic Gems III for details on this algorithm.

The filter member of the Image structure specifies which image filter to use. Blur specifies the blur factor where > 1 is blurry, < 1 is sharp.

The format of the ZoomImage method is:

> Image *ZoomImage ( Image *image, const unsigned int columns, const unsigned int rows );

A description of each parameter follows:

zoomed_image:

  Method ZoomImage returns a pointer to the image after scaling. A null image is returned if there is a memory shortage.

image:

  The address of a structure of type Image.

columns:

  An integer that specifies the number of columns in the zoomed image.

rows:

  An integer that specifies the number of rows in the scaled image.