0zoom - Methods to Resize an Image>/


NAME



!zoom - Methods to Resize an Image






(

SYNOPSIS



6magnify_image= MagnifyImage( image );



BImage * MinifyImage( Image *image );



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



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



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






B

FUNCTION DESCRIPTIONS






0

MagnifyImage



GMethod MagnifyImage creates a new image that is a integral size greaterIthan an existing one. It allocates the memory necessary for the new Image1structure and returns a pointer to the new image.



CMagnifyImage scans the reference image to create a magnify image byBbilinear interpolation. The magnify image columns and rows become:



  number_columns << 1  number_rows << 1




)The format of the MagnifyImage method is:

?
magnify_image=MagnifyImage ( image );


=A description of each parameter follows:


?

magnify_image:


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

"

image:


)The address of a structure of type Image.






.

MinifyImage



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



CMinifyImage scans the reference image to create a minified image byGcomputing the weighted average of a 4x4 cell centered at each referenceJpixel. 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




DWeights assume that the importance of neighboring pixels is negatelyCproportional to the square of their distance from the target pixel.



KThe scan only processes pixels that have a full set of neighbors. Pixels inKthe 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:


)

minify_image:


BMethod MinifyImage returns a pointer to the image after reducing. KA 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



KMethod SampleImage creates a new image that is a scaled size of an existingGone using pixel sampling. It allocates the memory necessary for the new7Image structure and returns a pointer to the new image.



(The format of the SampleImage method is:

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


=A description of each parameter follows:


)

sample_image:


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

"

image:


)The address of a structure of type Image.

$

columns:


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

!

rows:


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






,

ScaleImage



JMethod ScaleImage creates a new image that is a scaled size of an existingFone. It allocates the memory necessary for the new Image structure andJreturns a pointer to the new image. To scale a scanline from x pixels to yJpixels, each new pixel represents x/y old pixels. To read x/y pixels, readH(x/y rounded up) pixels but only count the required fraction of the lastHold pixel read in your new pixel. The remainder of the old pixel will becounted 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 ( Image *image, const unsigned int columns, const unsigned int rows );


=A description of each parameter follows:


(

scale_image:


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

"

image:


)The address of a structure of type Image.

$

columns:


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

!

rows:


AAn 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 7III for details on this algorithm.



HThe filter member of the Image structure specifies which image filter toEuse. Blur specifies the blur factor where > 1 is blurry, < 1 issharp.



&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:


'

zoom_image:


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

"

image:


)The address of a structure of type Image.

$

columns:


BAn integer that specifies the number of columns in the zoom image.

!

rows:


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