"L. Spiro Engine"
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

lsi::CResampler Class Reference

A resampler capable of resizing images up or down using various filters. More...

#include <LSIResampler.h>

List of all members.

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_LISTCreateContribList (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_LISTm_pclContribsX
LSI_CONTRIB_LISTm_pclContribsY
LSI_FILTERm_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_SCANLINEm_psScanBuffer
CVectorPoD< LSFLOAT, LSUINT32 > m_vScanBufferChunk
LSUINT32 m_ui32ScanChunkPos
LSUINT32 m_ui32LastSearchPos

Static Protected Attributes

static LSI_FILTER m_fFilters []

Detailed Description

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.


Member Typedef Documentation

A contribution to a single texel.

Contribution bounds.

References to contributions in a pool of contributions.

An array of contribution references.

Filter information.

A buffered scanline.

typedef LSFLOAT(LSE_CALL * lsi::CResampler::PfFilterFunc)(LSFLOAT _fT)

A filter function.

Parameters:
_fTThe value to pass through the filter.
Returns:
Returns the filtered value.

Member Enumeration Documentation

anonymous enum

Maximum scanline sample size.


Member Function Documentation

LSBOOL LSE_CALL lsi::CResampler::AddScanLine ( const LSFLOAT *  _pfScanline)

Add a scanline.

Parameters:
_pfScanlinePointer to the scan line to add. Must be at least the length of the source image width.
Returns:
Returns false if there is not enough memory to perform the operation.
LSE_INLINE LSDOUBLE LSE_CALL lsi::CResampler::Bessel0 ( LSDOUBLE  _dX) [static, protected]

A helper function.

Parameters:
_dXA happy parameter.
Returns:
Returns happiness.
static LSFLOAT LSE_CALL lsi::CResampler::BilinearFilterFunc ( LSFLOAT  _fT) [static, protected]

The tent/bilinear filter function.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
static LSFLOAT LSE_CALL lsi::CResampler::BoxFilterFunc ( LSFLOAT  _fT) [static, protected]

The box filter function.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
static LSFLOAT LSE_CALL lsi::CResampler::CatmullRomFilterFunc ( LSFLOAT  _fT) [static, protected]

The Catmull-Rom filter function.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
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.

Parameters:
_pfSamplesThe samples to clamp.
_ui32TotalThe total number of samples to which _pfSamples points.
_fLoThe low clamp value.
_fHiThe 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.

Parameters:
_i32TexelPosThe texel index to clamp.
_ui32SizeSize of the image. Provides the upper clamping range.
Returns:
Returns the clamped pixel index.
LSE_INLINE LSFLOAT LSE_CALL lsi::CResampler::Clean ( LSDOUBLE  _dVal) [static, protected]

Reject values below a specific epsilon.

Parameters:
_dValThe value to test.
Returns:
Returns the given value if it is above a certain epsilon or 0.
static LSUINT32 LSE_CALL lsi::CResampler::CountOps ( const LSI_CONTRIB_LIST _clList) [static, protected]

Count the operations in a contribution list.

Parameters:
_clListThe list whose operation count is to be obtained.
Returns:
Returns the number of operations in the contribution list.
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.

Parameters:
_ui32SrcSizeSize of the source.
_ui32DstSizeSize of the destination.
_pfFilterFilter function.
_fFilterSupportFilter support value.
_fFilterScaleFilter scale.
Returns:
Returns a new contribution list which must be freed via LSEDELETE.
LSI_CONTRIB_LIST* LSE_CALL lsi::CResampler::GetContribX ( )

Get the X contribution list.

Returns:
Returns the X contribution list for read and write.
LSI_CONTRIB_LIST* LSE_CALL lsi::CResampler::GetContribY ( )

Get the Y contribution list.

Returns:
Returns the Y contribution list for read and write.
const CVectorPoD<LSFLOAT, LSUINT32>* LSE_CALL lsi::CResampler::GetScanLine ( )

Get a scanline.

Returns:
Returns a pointer to a floating-point array that is the next 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.

Parameters:
_ui32SrcWidthSource width.
_ui32SrcHeightSource height.
_ui32DstWidthDestination width.
_ui32DstHeightDestination height.
_fSampleLowSample low frequency.
_fSampleHiSample high frequency.
_pcFilterName of the filter to use. Valid values are: "box", "lanczos4".
_pclContXContribution list for the X axis or NULL if one is to be made.
_pclContYContribution list for the Y axis or NULL if one is to be made.
_fFilterScaleXX-axis filter scale.
_fFilterScaleYY-axis filter scale.
_pvDstBufferA buffer the class can use for composing scanlines.
Returns:
Returns an error code indicating success or the reason for failure.
static LSFLOAT LSE_CALL lsi::CResampler::KaiserFilterFunc ( LSFLOAT  _fT) [static, protected]

The Kaiser filter function.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
LSE_INLINE LSDOUBLE LSE_CALL lsi::CResampler::KaiserHelper ( LSDOUBLE  _dAlpha,
LSDOUBLE  _dHalfWidth,
LSDOUBLE  _dX 
) [static, protected]

A helper function for the Kaiser filter.

Parameters:
_dAlphaA happy parameter.
_dHalfWidthA happy parameter.
_dXA happy parameter.
Returns:
Returns happiness.
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos12FilterFunc ( LSFLOAT  _fT) [static, protected]

The Lanczos filter function with 12 samples.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos3FilterFunc ( LSFLOAT  _fT) [static, protected]

The Lanczos filter function with 3 samples.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos4FilterFunc ( LSFLOAT  _fT) [static, protected]

The Lanczos filter function with 4 samples.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos64FilterFunc ( LSFLOAT  _fT) [static, protected]

The Lanczos filter function with 64 samples.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos6FilterFunc ( LSFLOAT  _fT) [static, protected]

The Lanczos filter function with 6 samples.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
static LSFLOAT LSE_CALL lsi::CResampler::Lanczos8FilterFunc ( LSFLOAT  _fT) [static, protected]

The Lanczos filter function with 8 samples.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
static LSFLOAT LSE_CALL lsi::CResampler::MitchellFilterFunc ( LSFLOAT  _fT) [static, protected]

The Mitchell filter function.

Parameters:
_fTThe value to filter.
Returns:
Returns the filtered value.
LSE_INLINE LSFLOAT LSE_CALL lsi::CResampler::MitchellFilterHelper ( LSFLOAT  _fT,
LSFLOAT  _fB,
LSFLOAT  _fC 
) [static, protected]

A helper function for the Mitchell filter.

Parameters:
_fTThe filter input.
_fBA happy parameter.
_fCA happy parameter.
Returns:
Returns happiness.
LSVOID LSE_CALL lsi::CResampler::ResampleX ( LSFLOAT *  _pfDst,
const LSFLOAT *  _pfSrc 
) const [protected]

Resample along the X axis.

Parameters:
_pfDstThe destination buffer into which to resample texels.
_pfSrcThe source buffer of texels.
LSVOID LSE_CALL lsi::CResampler::ResampleY ( CVectorPoD< LSFLOAT, LSUINT32 > &  _vDst) const [protected]

Resample along the Y axis.

Parameters:
_vDstThe 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.

Parameters:
_pfDstThe destination buffer.
_pfSrcThe source buffer.
_fScaleThe scaling to apply to each copy.
_ui32TotalNumber 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.

Parameters:
_pfDstThe destination buffer.
_pfSrcThe source buffer.
_fScaleThe scaling to apply to each copy.
_ui32TotalNumber of elements to copy.
LSE_INLINE LSDOUBLE LSE_CALL lsi::CResampler::SinC ( LSDOUBLE  _dX) [static, protected]

A helper function.

Parameters:
_dXA happy parameter.
Returns:
Returns happiness.

Member Data Documentation

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.

X contributions.

Y contributions.

The filter to use.

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.

The last chunk search position.

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator