6#ifndef iipr_TImagePixelInterpolator_included
7#define iipr_TImagePixelInterpolator_included
11#include <QtCore/QtGlobal>
12#include <QtCore/QtMath>
29template <
typename PixelComponentType>
40 PixelComponentType GetBilinearInterpolated(
float x,
float y,
int componentIndex)
const;
41 PixelComponentType GetBitmapPixelValue(
int x,
int y,
int componentIndex)
const;
44 PixelComponentType* m_imageBufferPtr;
45 int m_imageLineDifference;
48 int m_interpolationMode;
49 int m_pixelBytesCount;
56template <
typename PixelComponentType>
59 m_imageBufferPtr = (PixelComponentType*)bitmap.
GetLinePtr(0);
64 m_interpolationMode = interpolationMode;
65 m_maxValue = int(qPow(2.0,
double(
sizeof(PixelComponentType) * 8)) - 1);
69template <
typename PixelComponentType>
72 switch (m_interpolationMode){
74 return GetBitmapPixelValue(
int(x),
int(y), componentIndex);
77 return GetBilinearInterpolated(x, y, componentIndex);
80 qFatal(
"TImagePixelInterpolator: Unknown interpolation mode");
83 return GetBitmapPixelValue(
int(x),
int(y), componentIndex);
89template <
typename PixelComponentType>
98 float fx1 = 1.0f - fx;
99 float fy1 = 1.0f - fy;
101 float w1 = fx1 * fy1;
106 float v1 = w1 * GetBitmapPixelValue(px, py, componentIndex);
107 float v2 = w2 * GetBitmapPixelValue(px + 1, py, componentIndex);
108 float v3 = w3 * GetBitmapPixelValue(px, py + 1, componentIndex);
109 float v4 = w4 * GetBitmapPixelValue(px + 1, py + 1, componentIndex);
111 float retVal = v1 + v2 + v3 + v4;
112 if (retVal > m_maxValue){
116 return PixelComponentType(retVal);
120template <
typename PixelComponentType>
123 if (x < 0 || x >= m_imageWidth || y < 0 || y >= m_imageHeight){
127 return *(m_imageBufferPtr + x * m_pixelBytesCount + componentIndex + m_imageLineDifference * y);
Definition of single plane bitmap.
virtual int GetPixelBitsCount() const =0
Get total number of bits per single pixel.
virtual int GetLinesDifference() const =0
Get address difference between next and previous line.
virtual const void * GetLinePtr(int positionY) const =0
Get pointer to buffer for single line.
virtual istd::CIndex2d GetImageSize() const =0
Get size of this raster image.
PixelComponentType GetInterpolatedValue(float x, float y, int componentIndex) const
PixelComponentType PixelComponent
TImagePixelInterpolator(const iimg::IBitmap &image, int interpolationMode)
Contains the system indenendent definitions of image and related themes.
Contains the image processing classes.