AVIR
High-quality pro image resizing library
 All Classes Files Functions Variables Typedefs Macros
Classes | Public Member Functions | List of all members
avir::CImageResizer< fpclass > Class Template Reference

#include <avir.h>

Public Member Functions

 CImageResizer (const int aResBitDepth=8, const int aSrcBitDepth=0, const CImageResizerParams &aParams=CImageResizerParamsDef())
 
template<class Tin , class Tout >
void resizeImage (const Tin *const SrcBuf, const int SrcWidth, const int SrcHeight, int SrcScanlineSize, Tout *const NewBuf, const int NewWidth, const int NewHeight, const int ElCountIO, const double k, CImageResizerVars *const aVars=NULL) const
 

Detailed Description

template<class fpclass = fpclass_def< float >>
class avir::CImageResizer< fpclass >

Image resizer class.

The object of this class can be used to resize 1-4 channel images to any required size. Resizing is performed by utilizing interpolated sinc fractional delay filters plus (if necessary) a cascade of built-in sinc function-based 2X upsampling or 2X downsampling stages, followed by a correction filtering.

Object of this class can be allocated on stack.

Template Parameters
fpclassFloating-point processing definition class to use. See avir::fpclass_def for more details.

Constructor & Destructor Documentation

template<class fpclass = fpclass_def< float >>
avir::CImageResizer< fpclass >::CImageResizer ( const int  aResBitDepth = 8,
const int  aSrcBitDepth = 0,
const CImageResizerParams aParams = CImageResizerParamsDef() 
)

Constructor initializes the resizer.

Parameters
aResBitDepthRequired bit depth of resulting image (1-16). If integer value output is used (e.g. uint8_t), the bit depth also affects rounding: for example, if aResBitDepth=6 and "Tout" is uint8_t, the result will be rounded to 6 most significant bits (2 least significant bits truncated, with dithering applied).
aSrcBitDepthSource image's real bit-depth. Set to 0 to use aResBitDepth.
aParamsResizing algorithm's parameters to use. Leave out for default values. Can be useful when performing automatic optimization of parameters.

Member Function Documentation

template<class fpclass = fpclass_def< float >>
template<class Tin , class Tout >
void avir::CImageResizer< fpclass >::resizeImage ( const Tin *const  SrcBuf,
const int  SrcWidth,
const int  SrcHeight,
int  SrcScanlineSize,
Tout *const  NewBuf,
const int  NewWidth,
const int  NewHeight,
const int  ElCountIO,
const double  k,
CImageResizerVars *const  aVars = NULL 
) const

Function resizes image.

Parameters
SrcBufSource image buffer.
SrcWidthSource image width.
SrcHeightSource image height.
SrcScanlineSizePhysical size of source scanline in elements (not bytes). If this value is below 1, SrcWidth * ElCountIO will be used as the physical source scanline size.
[out]NewBufBuffer to accept the resized image. Can be equal to SrcBuf if the size of the resized image is smaller or equal to source image in size.
NewWidthNew image width.
NewHeightNew image height.
ElCountIOThe number of elements (channels) used to store each source and destination pixel (1-4).
kResizing step (one output pixel corresponds to "k" input pixels). A downsizing factor if > 1.0; upsizing factor if <= 1.0. Multiply by -1 if you would like to bypass "ox" and "oy" adjustment which is done by default to produce a centered image. If step value equals 0, the step value will be chosen automatically and independently for horizontal and vertical resizing.
[in,out]aVarsPointer to variables structure to be passed to the image resizing function. Can be NULL. Only variables that are initialized in default constructor of this structure are accepted by this function. These variables will not be changed by this function. All other variables can be modified by this function. The access to this object is not thread-safe, each concurrent instance of this function should use a separate aVars object.
Template Parameters
TinInput buffer element's type. Can be uint8_t (0-255 value range), uint16_t (0-65535 value range), float (0.0-1.0 value range), double (0.0-1.0 value range). Larger integer types are treated as uint16_t. Signed integer types are unsupported.
ToutOutput buffer element's type. Can be uint8_t (0-255 value range), uint16_t (0-65535 value range), float (0.0-1.0 value range), double (0.0-1.0 value range). Larger integer types are treated as uint16_t. Signed integer types are unsupported.