#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 |
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.
|
staticprotected |
Function performs final output of the resized scanline data to the destination image buffer. Variants for 1-4-channel image.
ip | Input resized scanline. |
op | Output image buffer. |
l | Pixel count. |
opinc | "op" increment, should account ElCount. |
IsIOFloat | "True" if float output and no clamping is necessary. |
Clamp | Clamp high level, used if IsIOFloat is "false". |
|
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.
ip | Source scanline buffer. |
rs | Scanline resizing positions object. |
l | Source scanline length, in pixels. |
ipinc | "ip" increment per pixel. |
|
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.
ip | Source scanline buffer. |
rs | Scanline resizing positions object. |
l | Source scanline length, in pixels. |
ipinc | "ip" increment per pixel. |
|
staticprotected |
Function performs internal scanline resizing. Variants for 1-4-channel images.
op | Destination buffer. |
DstLen | Destination length, in pixels. |
rp | Resizing positions and filters. |
kl | Filter kernel length, in taps. |
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.
SrcBuf | Source image buffer. | |
SrcWidth | Source image width. | |
SrcHeight | Source image height. | |
SrcScanlineSize | Physical 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] | NewBuf | Buffer 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. |
NewWidth | New image width. | |
NewHeight | New image height. | |
ElCount | The number of elements (channels) used to store each source and destination pixel (1-4). | |
kx0 | Resizing 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. | |
ky0 | Resizing step - vertical. Same as "kx". | |
ox | Start X pixel offset within source image (can be negative). Positive offset moves the image to the left. | |
oy | Start Y pixel offset within source image (can be negative). Positive offset moves the image to the top. |
T | Input 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. |
|
staticprotected |
Function rounds a value and applies clamping.
v | Value to round and clamp. |
Clamp | High clamp level, low level is 0. |
|
protected |
Intermediate resizing buffer.
|
protected |
Intermediate resizing buffer length.
|
protected |
Resizing filters for horizontal resizing.
|
protected |
Resizing filters for vertical resizing (may not be in use).
|
protected |
Horizontal resize scanline.
|
protected |
Vertical resize scanline.
|
protected |
Scanline buffer for vertical resizing.
|
protected |
Length of "spv".