21#include <osl/diagnose.h>
38 if ((nNewWidth > 1) && (nNewHeight > 1))
43 sal_Int32 nWidth = pReadAcc->
Width();
44 sal_Int32 nHeight = pReadAcc->
Height();
52 for (sal_Int32 nY = 0; nY < nHeight; nY++)
66 Scanline pScanline = pWriteAcc->GetScanline(nY);
67 for (sal_Int32 nX = 0; nX < nNewWidth; nX++)
69 pWriteAcc->SetPixelOnData(pScanline, nX, aCol0);
75 const sal_Int32 nNewWidth1 = nNewWidth - 1;
76 const sal_Int32 nWidth1 = pReadAcc->
Width() - 1;
77 const double fRevScaleX =
static_cast<double>(nWidth1) / nNewWidth1;
79 std::unique_ptr<sal_Int32[]> pLutInt(
new sal_Int32[nNewWidth]);
80 std::unique_ptr<sal_Int32[]> pLutFrac(
new sal_Int32[nNewWidth]);
82 for (sal_Int32 nX = 0, nTemp = nWidth - 2; nX < nNewWidth; nX++)
84 double fTemp = nX * fRevScaleX;
85 pLutInt[nX] =
MinMax(
static_cast<sal_Int32
>(fTemp), 0, nTemp);
87 pLutFrac[nX] =
static_cast<sal_Int32
>(fTemp * 1024.);
90 for (sal_Int32 nY = 0; nY < nHeight; nY++)
93 Scanline pScanline = pWriteAcc->GetScanline(nY);
94 for (sal_Int32 nX = 0; nX < nNewWidth; nX++)
96 sal_Int32 nTemp = pLutInt[nX];
112 nTemp = pLutFrac[nX];
114 sal_Int32 lXR0 = aCol0.
GetRed();
116 sal_Int32 lXB0 = aCol0.
GetBlue();
117 sal_Int32 lXR1 = aCol1.
GetRed() - lXR0;
118 sal_Int32 lXG1 = aCol1.
GetGreen() - lXG0;
119 sal_Int32 lXB1 = aCol1.
GetBlue() - lXB0;
122 static_cast<sal_uInt8>((lXR1 * nTemp + (lXR0 << 10)) >> 10));
124 static_cast<sal_uInt8>((lXG1 * nTemp + (lXG0 << 10)) >> 10));
126 static_cast<sal_uInt8>((lXB1 * nTemp + (lXB0 << 10)) >> 10));
128 pWriteAcc->SetPixelOnData(pScanline, nX, aCol0);
142 const Bitmap aOriginal(aBitmap);
148 if (pReadAcc && pWriteAcc)
151 OSL_ENSURE(!pReadAcc->
HasPalette(),
"OOps, somehow ImplScaleInterpolate "
152 "in-between format has palette, should not "
157 for (sal_Int32 nX = 0; nX < nNewWidth; nX++)
161 for (sal_Int32 nY = 0; nY < nNewHeight; nY++)
163 pWriteAcc->SetPixel(nY, nX, aCol0);
169 const sal_Int32 nNewHeight1 = nNewHeight - 1;
170 const sal_Int32 nHeight1 = pReadAcc->
Height() - 1;
171 const double fRevScaleY =
static_cast<double>(nHeight1) / nNewHeight1;
173 std::unique_ptr<sal_Int32[]> pLutInt(
new sal_Int32[nNewHeight]);
174 std::unique_ptr<sal_Int32[]> pLutFrac(
new sal_Int32[nNewHeight]);
176 for (sal_Int32 nY = 0, nTemp = nHeight - 2; nY < nNewHeight; nY++)
178 double fTemp = nY * fRevScaleY;
179 pLutInt[nY] =
MinMax(
static_cast<sal_Int32
>(fTemp), 0, nTemp);
180 fTemp -= pLutInt[nY];
181 pLutFrac[nY] =
static_cast<sal_Int32
>(fTemp * 1024.);
184 for (sal_Int32 nX = 0; nX < nNewWidth; nX++)
186 for (sal_Int32 nY = 0; nY < nNewHeight; nY++)
188 sal_Int32 nTemp = pLutInt[nY];
193 nTemp = pLutFrac[nY];
195 sal_Int32 lXR0 = aCol0.
GetRed();
197 sal_Int32 lXB0 = aCol0.
GetBlue();
198 sal_Int32 lXR1 = aCol1.
GetRed() - lXR0;
199 sal_Int32 lXG1 = aCol1.
GetGreen() - lXG0;
200 sal_Int32 lXB1 = aCol1.
GetBlue() - lXB0;
203 static_cast<sal_uInt8>((lXR1 * nTemp + (lXR0 << 10)) >> 10));
205 static_cast<sal_uInt8>((lXG1 * nTemp + (lXG0 << 10)) >> 10));
207 static_cast<sal_uInt8>((lXB1 * nTemp + (lXB0 << 10)) >> 10));
209 pWriteAcc->SetPixel(nY, nX, aCol0);
vcl::ScopedBitmapAccess< BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess > BitmapScopedWriteAccess
Bitmap GetBitmap(Color aTransparentReplaceColor) const
static bool Filter(BitmapEx &rBmpEx, BitmapFilter const &rFilter)
tools::Long Height() const
tools::Long Width() const
const BitmapColor & GetPaletteColor(sal_uInt16 nColor) const
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const override
BitmapColor GetPixel(tools::Long nY, tools::Long nX) const
BitmapColor GetPixelFromData(const sal_uInt8 *pData, tools::Long nX) const
sal_uInt8 GetIndexFromData(const sal_uInt8 *pData, tools::Long nX) const
Scanline GetScanline(tools::Long nY) const
Size GetSizePixel() const
vcl::ScopedBitmapAccess< BitmapReadAccess, Bitmap, &Bitmap::AcquireReadAccess > ScopedReadAccess
void AdaptBitCount(Bitmap &rNew) const
sal_uInt8 GetBlue() const
void SetGreen(sal_uInt8 nGreen)
void SetRed(sal_uInt8 nRed)
sal_uInt8 GetGreen() const
void SetBlue(sal_uInt8 nBlue)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
tools::Long FRound(double fVal)
std::enable_if< std::is_signed< T >::value||std::is_floating_point< T >::value, long >::type MinMax(T nVal, tools::Long nMin, tools::Long nMax)