AVIR
High-quality pro image resizing library
 All Classes Files Functions Variables Typedefs Macros
Classes | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
avir::CLancIR Class Reference

#include <lancir.h>

Classes

class  CResizeFilters
 
struct  CResizePos
 
class  CResizeScanline
 

Public Member Functions

template<class T >
void resizeImage (const T *const SrcBuf, const int SrcWidth, const int SrcHeight, int SrcScanlineSize, T *const NewBuf, const int NewWidth, const int NewHeight, const int ElCount, const double kx0=0.0, const double ky0=0.0, double ox=0.0, double oy=0.0)
 

Static Protected Member Functions

template<class T >
static void copyOutput1 (const float *ip, T *op, int l, const int opinc, const bool IsIOFloat, const int Clamp)
 
template<class T >
static void copyOutput2 (const float *ip, T *op, int l, const int opinc, const bool IsIOFloat, const int Clamp)
 
template<class T >
static void copyOutput3 (const float *ip, T *op, int l, const int opinc, const bool IsIOFloat, const int Clamp)
 
template<class T >
static void copyOutput4 (const float *ip, T *op, int l, const int opinc, const bool IsIOFloat, const int Clamp)
 
template<class T >
static void copyScanline1h (const T *ip, CResizeScanline &rs, const int l)
 
template<class T >
static void copyScanline1v (const T *ip, CResizeScanline &rs, const int l, const int ipinc)
 
template<class T >
static void copyScanline2h (const T *ip, CResizeScanline &rs, const int l)
 
template<class T >
static void copyScanline2v (const T *ip, CResizeScanline &rs, const int l, const int ipinc)
 
template<class T >
static void copyScanline3h (const T *ip, CResizeScanline &rs, const int l)
 
template<class T >
static void copyScanline3v (const T *ip, CResizeScanline &rs, const int l, const int ipinc)
 
template<class T >
static void copyScanline4h (const T *ip, CResizeScanline &rs, const int l)
 
template<class T >
static void copyScanline4v (const T *ip, CResizeScanline &rs, const int l, const int ipinc)
 
static void resize1 (float *op, int DstLen, CResizePos *rp, const int kl)
 
static void resize2 (float *op, int DstLen, CResizePos *rp, const int kl)
 
static void resize3 (float *op, int DstLen, CResizePos *rp, const int kl)
 
static void resize4 (float *op, int DstLen, CResizePos *rp, const int kl)
 
static int roundclamp (const float v, const int Clamp)
 

Protected Attributes

float * FltBuf
 
size_t FltBufLen
 
CResizeFilters rfh
 
CResizeFilters rfv0
 
CResizeScanline rsh
 
CResizeScanline rsv
 
float * spv
 
int spvlen
 

Detailed Description

LANCIR 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 Lanczos filters, with 8-bit precision. This class offers a kind of "optimal" Lanczos resampling implementation.

Object of this class can be allocated on stack.

Note that object of this class does not free temporary buffers and variables after the resizeImage() call (until object's destruction), these buffers are reused on subsequent calls making batch resizing of same-size images faster. This means resizing is not thread-safe: a separate object should be created for each thread.

Member Function Documentation

template<class T >
static void avir::CLancIR::copyOutput1 ( const float *  ip,
T *  op,
int  l,
const int  opinc,
const bool  IsIOFloat,
const int  Clamp 
)
staticprotected

Function performs final output of the resized scanline data to the destination image buffer. Variants for 1-4-channel image.

Parameters
ipInput resized scanline.
opOutput image buffer.
lPixel count.
opinc"op" increment, should account ElCount.
IsIOFloat"True" if float output and no clamping is necessary.
ClampClamp high level, used if IsIOFloat is "false".
template<class T >
static void avir::CLancIR::copyScanline1h ( const T *  ip,
CResizeScanline rs,
const int  l 
)
staticprotected

Function copies scanline from the source buffer in its native format to internal scanline buffer, in preparation for horizontal resizing. Variants for 1-4-channel images.

Parameters
ipSource scanline buffer.
rsScanline resizing positions object.
lSource scanline length, in pixels.
ipinc"ip" increment per pixel.
template<class T >
static void avir::CLancIR::copyScanline1v ( const T *  ip,
CResizeScanline rs,
const int  l,
const int  ipinc 
)
staticprotected

Function copies scanline from the source buffer in its native format to internal scanline buffer, in preparation for vertical resizing. Variants for 1-4-channel images.

Parameters
ipSource scanline buffer.
rsScanline resizing positions object.
lSource scanline length, in pixels.
ipinc"ip" increment per pixel.
static void avir::CLancIR::resize1 ( float *  op,
int  DstLen,
CResizePos rp,
const int  kl 
)
staticprotected

Function performs internal scanline resizing. Variants for 1-4-channel images.

Parameters
opDestination buffer.
DstLenDestination length, in pixels.
rpResizing positions and filters.
klFilter kernel length, in taps.
template<class T >
void avir::CLancIR::resizeImage ( const T *const  SrcBuf,
const int  SrcWidth,
const int  SrcHeight,
int  SrcScanlineSize,
T *const  NewBuf,
const int  NewWidth,
const int  NewHeight,
const int  ElCount,
const double  kx0 = 0.0,
const double  ky0 = 0.0,
double  ox = 0.0,
double  oy = 0.0 
)

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 * ElCount 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.
ElCountThe number of elements (channels) used to store each source and destination pixel (1-4).
kx0Resizing step - horizontal (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.
ky0Resizing step - vertical. Same as "kx".
oxStart X pixel offset within source image (can be negative). Positive offset moves the image to the left.
oyStart Y pixel offset within source image (can be negative). Positive offset moves the image to the top.
Template Parameters
TInput and output buffer element's type. Can be uint8_t (0-255 value range), uint16_t (0-65535 value range), float (any value range), double (any value range). Larger integer types are treated as uint16_t. Signed integer types are unsupported.
static int avir::CLancIR::roundclamp ( const float  v,
const int  Clamp 
)
staticprotected

Function rounds a value and applies clamping.

Parameters
vValue to round and clamp.
ClampHigh clamp level, low level is 0.

Member Data Documentation

float* avir::CLancIR::FltBuf
protected

Intermediate resizing buffer.

size_t avir::CLancIR::FltBufLen
protected

Intermediate resizing buffer length.

CResizeFilters avir::CLancIR::rfh
protected

Resizing filters for horizontal resizing.

CResizeFilters avir::CLancIR::rfv0
protected

Resizing filters for vertical resizing (may not be in use).

CResizeScanline avir::CLancIR::rsh
protected

Horizontal resize scanline.

CResizeScanline avir::CLancIR::rsv
protected

Vertical resize scanline.

float* avir::CLancIR::spv
protected

Scanline buffer for vertical resizing.

int avir::CLancIR::spvlen
protected

Length of "spv".