"L. Spiro Engine"
|
A resampler capable of resizing images up or down using various filters. More...
#include <LSIResampler.h>
Classes | |
struct | LSI_CONTRIB |
struct | LSI_CONTRIB_BOUNDS |
struct | LSI_CONTRIB_EX |
struct | LSI_CONTRIB_LIST |
struct | LSI_FILTER |
struct | LSI_SCANLINE |
Public Types | |
enum | { LSI_MAX_SCANLINE = 16384 } |
typedef struct lsi::CResampler::LSI_CONTRIB * | LPLSI_CONTRIB |
typedef struct lsi::CResampler::LSI_CONTRIB | LPCLSI_CONTRIB |
typedef struct lsi::CResampler::LSI_CONTRIB_EX * | LPLSI_CONTRIB_EX |
typedef struct lsi::CResampler::LSI_CONTRIB_EX | LPCLSI_CONTRIB_EX |
typedef struct lsi::CResampler::LSI_CONTRIB_LIST * | LPLSI_CONTRIB_LIST |
typedef struct lsi::CResampler::LSI_CONTRIB_LIST | LPCLSI_CONTRIB_LIST |
typedef struct lsi::CResampler::LSI_SCANLINE * | LPLSI_SCANLINE |
typedef struct lsi::CResampler::LSI_SCANLINE | LPCLSI_SCANLINE |
typedef LSFLOAT(LSE_CALL * | PfFilterFunc )(LSFLOAT _fT) |
typedef struct lsi::CResampler::LSI_FILTER * | LPLSI_FILTER |
typedef struct lsi::CResampler::LSI_FILTER | LPCLSI_FILTER |
Public Member Functions | |
LSSTD_ERRORS LSE_CALL | InitResampler (LSUINT32 _ui32SrcWidth, LSUINT32 _ui32SrcHeight, LSUINT32 _ui32DstWidth, LSUINT32 _ui32DstHeight, LSFLOAT _fSampleLow=0.0f, LSFLOAT _fSampleHi=1.0f, const LSCHAR *_pcFilter="lanczos4", LSI_CONTRIB_LIST *_pclContX=NULL, LSI_CONTRIB_LIST *_pclContY=NULL, LSFLOAT _fFilterScaleX=1.0f, LSFLOAT _fFilterScaleY=1.0f, CVectorPoD< LSFLOAT, LSUINT32 > *_pvDstBuffer=NULL) |
LSI_CONTRIB_LIST *LSE_CALL | GetContribX () |
LSI_CONTRIB_LIST *LSE_CALL | GetContribY () |
LSBOOL LSE_CALL | AddScanLine (const LSFLOAT *_pfScanline) |
const CVectorPoD< LSFLOAT, LSUINT32 > *LSE_CALL | GetScanLine () |
Protected Types | |
typedef struct lsi::CResampler::LSI_CONTRIB_BOUNDS * | LPLSI_CONTRIB_BOUNDS |
typedef struct lsi::CResampler::LSI_CONTRIB_BOUNDS | LPCLSI_CONTRIB_BOUNDS |
Protected Member Functions | |
LSVOID LSE_CALL | ResampleX (LSFLOAT *_pfDst, const LSFLOAT *_pfSrc) const |
LSVOID LSE_CALL | ResampleY (CVectorPoD< LSFLOAT, LSUINT32 > &_vDst) const |
Static Protected Member Functions | |
static LSVOID LSE_CALL | ScaleY (CVectorPoD< LSFLOAT, LSUINT32 > &_pfDst, const LSFLOAT *_pfSrc, LSFLOAT _fScale, LSUINT32 _ui32Total) |
static LSVOID LSE_CALL | ScaleYAdd (CVectorPoD< LSFLOAT, LSUINT32 > &_pfDst, const LSFLOAT *_pfSrc, LSFLOAT _fScale, LSUINT32 _ui32Total) |
static LSVOID LSE_CALL | ClampSamples (LSFLOAT *_pfSamples, LSUINT32 _ui32Total, LSFLOAT _fLo, LSFLOAT _fHi) |
static LSI_CONTRIB_LIST * | CreateContribList (LSUINT32 _ui32SrcSize, LSUINT32 _ui32DstSize, PfFilterFunc _pfFilter, LSFLOAT _fFilterSupport, LSFLOAT _fFilterScale) |
static LSINT32 LSE_CALL | ClampTexel (LSINT32 _i32TexelPos, LSUINT32 _ui32Size) |
static LSUINT32 LSE_CALL | CountOps (const LSI_CONTRIB_LIST &_clList) |
static LSE_INLINE LSFLOAT LSE_CALL | Clean (LSDOUBLE _dVal) |
static LSE_INLINE LSDOUBLE LSE_CALL | KaiserHelper (LSDOUBLE _dAlpha, LSDOUBLE _dHalfWidth, LSDOUBLE _dX) |
static LSE_INLINE LSFLOAT LSE_CALL | MitchellFilterHelper (LSFLOAT _fT, LSFLOAT _fB, LSFLOAT _fC) |
static LSE_INLINE LSDOUBLE LSE_CALL | Bessel0 (LSDOUBLE _dX) |
static LSE_INLINE LSDOUBLE LSE_CALL | SinC (LSDOUBLE _dX) |
static LSFLOAT LSE_CALL | BoxFilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | BilinearFilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | KaiserFilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | Lanczos3FilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | Lanczos4FilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | Lanczos6FilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | Lanczos8FilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | Lanczos12FilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | Lanczos64FilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | MitchellFilterFunc (LSFLOAT _fT) |
static LSFLOAT LSE_CALL | CatmullRomFilterFunc (LSFLOAT _fT) |
Protected Attributes | |
LSI_CONTRIB_LIST * | m_pclContribsX |
LSI_CONTRIB_LIST * | m_pclContribsY |
LSI_FILTER * | m_pfFilter |
LSBOOL | m_bBorrowedX |
LSBOOL | m_bBorrowedY |
LSFLOAT | m_fLow |
LSFLOAT | m_fHi |
LSUINT32 | m_ui32SrcWidth |
LSUINT32 | m_ui32SrcHeight |
LSUINT32 | m_ui32DstWidth |
LSUINT32 | m_ui32DstHeight |
LSUINT32 | m_ui32CurSrcY |
LSUINT32 | m_ui32CurDstY |
LSUINT32 | m_ui32IntermX |
LSBOOL | m_bDelayX |
CVectorPoD< LSINT32, LSUINT32 > | m_vSrcCountY |
CVectorPoD< LSUINT8, LSUINT32 > | m_vSrcFlagsY |
CVectorPoD< LSFLOAT, LSUINT32 > * | m_pvDstBuffer |
CVectorPoD< LSFLOAT, LSUINT32 > | m_vTempBuffer |
LSI_SCANLINE * | m_psScanBuffer |
CVectorPoD< LSFLOAT, LSUINT32 > | m_vScanBufferChunk |
LSUINT32 | m_ui32ScanChunkPos |
LSUINT32 | m_ui32LastSearchPos |
Static Protected Attributes | |
static LSI_FILTER | m_fFilters [] |
A resampler capable of resizing images up or down using various filters.
Class CResampler Description: A resampler capable of resizing images up or down using various filters. This is a heavily modified port of Rich Geldreich's open-source resampler demonstration code.
typedef struct lsi::CResampler::LSI_CONTRIB * lsi::CResampler::LPLSI_CONTRIB |
A contribution to a single texel.
typedef struct lsi::CResampler::LSI_CONTRIB_BOUNDS * lsi::CResampler::LPLSI_CONTRIB_BOUNDS [protected] |
Contribution bounds.
typedef struct lsi::CResampler::LSI_CONTRIB_EX * lsi::CResampler::LPLSI_CONTRIB_EX |
References to contributions in a pool of contributions.
typedef struct lsi::CResampler::LSI_CONTRIB_LIST * lsi::CResampler::LPLSI_CONTRIB_LIST |
An array of contribution references.
typedef struct lsi::CResampler::LSI_FILTER * lsi::CResampler::LPLSI_FILTER |
Filter information.
typedef struct lsi::CResampler::LSI_SCANLINE * lsi::CResampler::LPLSI_SCANLINE |
A buffered scanline.
typedef LSFLOAT(LSE_CALL * lsi::CResampler::PfFilterFunc)(LSFLOAT _fT) |
A filter function.
_fT | The value to pass through the filter. |
anonymous enum |
Maximum scanline sample size.
LSBOOL LSE_CALL lsi::CResampler::AddScanLine | ( | const LSFLOAT * | _pfScanline | ) |
Add a scanline.
_pfScanline | Pointer to the scan line to add. Must be at least the length of the source image width. |
LSE_INLINE LSDOUBLE LSE_CALL lsi::CResampler::Bessel0 | ( | LSDOUBLE | _dX | ) | [static, protected] |
A helper function.
_dX | A happy parameter. |
static LSFLOAT LSE_CALL lsi::CResampler::BilinearFilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The tent/bilinear filter function.
_fT | The value to filter. |
static LSFLOAT LSE_CALL lsi::CResampler::BoxFilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The box filter function.
_fT | The value to filter. |
static LSFLOAT LSE_CALL lsi::CResampler::CatmullRomFilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Catmull-Rom filter function.
_fT | The value to filter. |
static LSVOID LSE_CALL lsi::CResampler::ClampSamples | ( | LSFLOAT * | _pfSamples, |
LSUINT32 | _ui32Total, | ||
LSFLOAT | _fLo, | ||
LSFLOAT | _fHi | ||
) | [static, protected] |
Clamp all the samples into a certain range.
_pfSamples | The samples to clamp. |
_ui32Total | The total number of samples to which _pfSamples points. |
_fLo | The low clamp value. |
_fHi | The high clamp value. |
static LSINT32 LSE_CALL lsi::CResampler::ClampTexel | ( | LSINT32 | _i32TexelPos, |
LSUINT32 | _ui32Size | ||
) | [static, protected] |
Clamps a text coordinate between 0 and the given size.
_i32TexelPos | The texel index to clamp. |
_ui32Size | Size of the image. Provides the upper clamping range. |
LSE_INLINE LSFLOAT LSE_CALL lsi::CResampler::Clean | ( | LSDOUBLE | _dVal | ) | [static, protected] |
Reject values below a specific epsilon.
_dVal | The value to test. |
static LSUINT32 LSE_CALL lsi::CResampler::CountOps | ( | const LSI_CONTRIB_LIST & | _clList | ) | [static, protected] |
Count the operations in a contribution list.
_clList | The list whose operation count is to be obtained. |
static LSI_CONTRIB_LIST* lsi::CResampler::CreateContribList | ( | LSUINT32 | _ui32SrcSize, |
LSUINT32 | _ui32DstSize, | ||
PfFilterFunc | _pfFilter, | ||
LSFLOAT | _fFilterSupport, | ||
LSFLOAT | _fFilterScale | ||
) | [static, protected] |
Allocates and returns a new contribution list. If NULL is not returned, the list must be deallocated via LSEDELETE.
_ui32SrcSize | Size of the source. |
_ui32DstSize | Size of the destination. |
_pfFilter | Filter function. |
_fFilterSupport | Filter support value. |
_fFilterScale | Filter scale. |
LSI_CONTRIB_LIST* LSE_CALL lsi::CResampler::GetContribX | ( | ) |
Get the X contribution list.
LSI_CONTRIB_LIST* LSE_CALL lsi::CResampler::GetContribY | ( | ) |
Get the Y contribution list.
const CVectorPoD<LSFLOAT, LSUINT32>* LSE_CALL lsi::CResampler::GetScanLine | ( | ) |
Get a scanline.
LSSTD_ERRORS LSE_CALL lsi::CResampler::InitResampler | ( | LSUINT32 | _ui32SrcWidth, |
LSUINT32 | _ui32SrcHeight, | ||
LSUINT32 | _ui32DstWidth, | ||
LSUINT32 | _ui32DstHeight, | ||
LSFLOAT | _fSampleLow = 0.0f , |
||
LSFLOAT | _fSampleHi = 1.0f , |
||
const LSCHAR * | _pcFilter = "lanczos4" , |
||
LSI_CONTRIB_LIST * | _pclContX = NULL , |
||
LSI_CONTRIB_LIST * | _pclContY = NULL , |
||
LSFLOAT | _fFilterScaleX = 1.0f , |
||
LSFLOAT | _fFilterScaleY = 1.0f , |
||
CVectorPoD< LSFLOAT, LSUINT32 > * | _pvDstBuffer = NULL |
||
) |
Prepare for resampling.
_ui32SrcWidth | Source width. |
_ui32SrcHeight | Source height. |
_ui32DstWidth | Destination width. |
_ui32DstHeight | Destination height. |
_fSampleLow | Sample low frequency. |
_fSampleHi | Sample high frequency. |
_pcFilter | Name of the filter to use. Valid values are: "box", "lanczos4". |
_pclContX | Contribution list for the X axis or NULL if one is to be made. |
_pclContY | Contribution list for the Y axis or NULL if one is to be made. |
_fFilterScaleX | X-axis filter scale. |
_fFilterScaleY | Y-axis filter scale. |
_pvDstBuffer | A buffer the class can use for composing scanlines. |
static LSFLOAT LSE_CALL lsi::CResampler::KaiserFilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Kaiser filter function.
_fT | The value to filter. |
LSE_INLINE LSDOUBLE LSE_CALL lsi::CResampler::KaiserHelper | ( | LSDOUBLE | _dAlpha, |
LSDOUBLE | _dHalfWidth, | ||
LSDOUBLE | _dX | ||
) | [static, protected] |
A helper function for the Kaiser filter.
_dAlpha | A happy parameter. |
_dHalfWidth | A happy parameter. |
_dX | A happy parameter. |
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos12FilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Lanczos filter function with 12 samples.
_fT | The value to filter. |
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos3FilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Lanczos filter function with 3 samples.
_fT | The value to filter. |
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos4FilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Lanczos filter function with 4 samples.
_fT | The value to filter. |
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos64FilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Lanczos filter function with 64 samples.
_fT | The value to filter. |
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos6FilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Lanczos filter function with 6 samples.
_fT | The value to filter. |
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos8FilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Lanczos filter function with 8 samples.
_fT | The value to filter. |
static LSFLOAT LSE_CALL lsi::CResampler::MitchellFilterFunc | ( | LSFLOAT | _fT | ) | [static, protected] |
The Mitchell filter function.
_fT | The value to filter. |
LSE_INLINE LSFLOAT LSE_CALL lsi::CResampler::MitchellFilterHelper | ( | LSFLOAT | _fT, |
LSFLOAT | _fB, | ||
LSFLOAT | _fC | ||
) | [static, protected] |
A helper function for the Mitchell filter.
_fT | The filter input. |
_fB | A happy parameter. |
_fC | A happy parameter. |
LSVOID LSE_CALL lsi::CResampler::ResampleX | ( | LSFLOAT * | _pfDst, |
const LSFLOAT * | _pfSrc | ||
) | const [protected] |
Resample along the X axis.
_pfDst | The destination buffer into which to resample texels. |
_pfSrc | The source buffer of texels. |
LSVOID LSE_CALL lsi::CResampler::ResampleY | ( | CVectorPoD< LSFLOAT, LSUINT32 > & | _vDst | ) | const [protected] |
Resample along the Y axis.
_vDst | The destination buffer into which to resample texels. |
static LSVOID LSE_CALL lsi::CResampler::ScaleY | ( | CVectorPoD< LSFLOAT, LSUINT32 > & | _pfDst, |
const LSFLOAT * | _pfSrc, | ||
LSFLOAT | _fScale, | ||
LSUINT32 | _ui32Total | ||
) | [static, protected] |
Copy from one buffer to another, scaling each component.
_pfDst | The destination buffer. |
_pfSrc | The source buffer. |
_fScale | The scaling to apply to each copy. |
_ui32Total | Number of elements to copy. |
static LSVOID LSE_CALL lsi::CResampler::ScaleYAdd | ( | CVectorPoD< LSFLOAT, LSUINT32 > & | _pfDst, |
const LSFLOAT * | _pfSrc, | ||
LSFLOAT | _fScale, | ||
LSUINT32 | _ui32Total | ||
) | [static, protected] |
Add values from one buffer to another, scaling each component.
_pfDst | The destination buffer. |
_pfSrc | The source buffer. |
_fScale | The scaling to apply to each copy. |
_ui32Total | Number of elements to copy. |
LSE_INLINE LSDOUBLE LSE_CALL lsi::CResampler::SinC | ( | LSDOUBLE | _dX | ) | [static, protected] |
A helper function.
_dX | A happy parameter. |
LSBOOL lsi::CResampler::m_bBorrowedX [protected] |
If true, the X contibution list is borrowed.
LSBOOL lsi::CResampler::m_bBorrowedY [protected] |
If true, the Y contibution list is borrowed.
LSBOOL lsi::CResampler::m_bDelayX [protected] |
Delay the X?
LSI_FILTER lsi::CResampler::m_fFilters[] [static, protected] |
Filter functions.
LSFLOAT lsi::CResampler::m_fHi [protected] |
Sample high.
LSFLOAT lsi::CResampler::m_fLow [protected] |
Sample low.
LSI_CONTRIB_LIST* lsi::CResampler::m_pclContribsX [protected] |
X contributions.
LSI_CONTRIB_LIST* lsi::CResampler::m_pclContribsY [protected] |
Y contributions.
LSI_FILTER* lsi::CResampler::m_pfFilter [protected] |
The filter to use.
LSI_SCANLINE* lsi::CResampler::m_psScanBuffer [protected] |
Scanline buffer.
CVectorPoD<LSFLOAT, LSUINT32>* lsi::CResampler::m_pvDstBuffer [protected] |
Destination sampler buffer.
LSUINT32 lsi::CResampler::m_ui32CurDstY [protected] |
Current destination Y.
LSUINT32 lsi::CResampler::m_ui32CurSrcY [protected] |
Current source Y.
LSUINT32 lsi::CResampler::m_ui32DstHeight [protected] |
Destination height.
LSUINT32 lsi::CResampler::m_ui32DstWidth [protected] |
Destination width.
LSUINT32 lsi::CResampler::m_ui32IntermX [protected] |
Intermediate X.
LSUINT32 lsi::CResampler::m_ui32LastSearchPos [protected] |
The last chunk search position.
LSUINT32 lsi::CResampler::m_ui32ScanChunkPos [protected] |
Current position within the chunk.
LSUINT32 lsi::CResampler::m_ui32SrcHeight [protected] |
Source height.
LSUINT32 lsi::CResampler::m_ui32SrcWidth [protected] |
Source width.
CVectorPoD<LSFLOAT, LSUINT32> lsi::CResampler::m_vScanBufferChunk [protected] |
A chunk allocated for use by the scanline buffer.
CVectorPoD<LSINT32, LSUINT32> lsi::CResampler::m_vSrcCountY [mutable, protected] |
Source Y count.
CVectorPoD<LSUINT8, LSUINT32> lsi::CResampler::m_vSrcFlagsY [mutable, protected] |
Source Y flags.
CVectorPoD<LSFLOAT, LSUINT32> lsi::CResampler::m_vTempBuffer [mutable, protected] |
Temporary sampler buffer.