summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-12-15 20:37:57 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-12-16 09:40:34 +0100
commit5cfb92d11de73aba88dce809cc0355a8d9c23e95 (patch)
treebd541ee0fe779ecd00d943d3cb6565c1dd29cc4f /vcl
parent85057da7f19e8e5d6023c16fa07d138e2b519a66 (diff)
crashtesting: Assertion `nMin <= nMax' failed in MinMax
MinMax(T, tools::Long, tools::Long) [T = int]: Assertion `nMin <= nMax' failed. seen since commit 374e261ad1ea8b41f5ecdd850c27fdc961c4868b Date: Sun Dec 5 11:55:58 2021 +0100 increase maximum document thumbnail size from 256 to 512 but presumably always lurked previously. This commit is supposed to change nothing, just rearrange to show that the nWidth == 1 branch (and adapted the nHeight == 1 branch too) doesn't use the data generated by the asserting block and move that block into the nWidth/nHeight != 1 branches Change-Id: I1d3284ee32c1eff738c34bc252400726dc7632b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126895 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx81
1 files changed, 44 insertions, 37 deletions
diff --git a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
index 5ff3c23ad1e9..ce32f2512163 100644
--- a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
+++ b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
@@ -47,26 +47,11 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const
if (pWriteAcc)
{
- const sal_Int32 nNewWidth1 = nNewWidth - 1;
- const sal_Int32 nWidth1 = pReadAcc->Width() - 1;
- const double fRevScaleX = static_cast<double>(nWidth1) / nNewWidth1;
-
- std::unique_ptr<sal_Int32[]> pLutInt(new sal_Int32[nNewWidth]);
- std::unique_ptr<sal_Int32[]> pLutFrac(new sal_Int32[nNewWidth]);
-
- for (sal_Int32 nX = 0, nTemp = nWidth - 2; nX < nNewWidth; nX++)
- {
- double fTemp = nX * fRevScaleX;
- pLutInt[nX] = MinMax(static_cast<sal_Int32>(fTemp), 0, nTemp);
- fTemp -= pLutInt[nX];
- pLutFrac[nX] = static_cast<sal_Int32>(fTemp * 1024.);
- }
-
- for (sal_Int32 nY = 0; nY < nHeight; nY++)
+ if (1 == nWidth)
{
- Scanline pScanlineRead = pReadAcc->GetScanline(nY);
- if (1 == nWidth)
+ for (sal_Int32 nY = 0; nY < nHeight; nY++)
{
+ Scanline pScanlineRead = pReadAcc->GetScanline(nY);
BitmapColor aCol0;
if (pReadAcc->HasPalette())
{
@@ -84,8 +69,27 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const
pWriteAcc->SetPixelOnData(pScanline, nX, aCol0);
}
}
- else
+ }
+ else
+ {
+ const sal_Int32 nNewWidth1 = nNewWidth - 1;
+ const sal_Int32 nWidth1 = pReadAcc->Width() - 1;
+ const double fRevScaleX = static_cast<double>(nWidth1) / nNewWidth1;
+
+ std::unique_ptr<sal_Int32[]> pLutInt(new sal_Int32[nNewWidth]);
+ std::unique_ptr<sal_Int32[]> pLutFrac(new sal_Int32[nNewWidth]);
+
+ for (sal_Int32 nX = 0, nTemp = nWidth - 2; nX < nNewWidth; nX++)
{
+ double fTemp = nX * fRevScaleX;
+ pLutInt[nX] = MinMax(static_cast<sal_Int32>(fTemp), 0, nTemp);
+ fTemp -= pLutInt[nX];
+ pLutFrac[nX] = static_cast<sal_Int32>(fTemp * 1024.);
+ }
+
+ for (sal_Int32 nY = 0; nY < nHeight; nY++)
+ {
+ Scanline pScanlineRead = pReadAcc->GetScanline(nY);
Scanline pScanline = pWriteAcc->GetScanline(nY);
for (sal_Int32 nX = 0; nX < nNewWidth; nX++)
{
@@ -143,29 +147,14 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const
if (pReadAcc && pWriteAcc)
{
- const sal_Int32 nNewHeight1 = nNewHeight - 1;
- const sal_Int32 nHeight1 = pReadAcc->Height() - 1;
- const double fRevScaleY = static_cast<double>(nHeight1) / nNewHeight1;
-
- std::unique_ptr<sal_Int32[]> pLutInt(new sal_Int32[nNewHeight]);
- std::unique_ptr<sal_Int32[]> pLutFrac(new sal_Int32[nNewHeight]);
-
- for (sal_Int32 nY = 0, nTemp = nHeight - 2; nY < nNewHeight; nY++)
- {
- double fTemp = nY * fRevScaleY;
- pLutInt[nY] = MinMax(static_cast<sal_Int32>(fTemp), 0, nTemp);
- fTemp -= pLutInt[nY];
- pLutFrac[nY] = static_cast<sal_Int32>(fTemp * 1024.);
- }
-
// after 1st step, bitmap *is* 24bit format (see above)
OSL_ENSURE(!pReadAcc->HasPalette(), "OOps, somehow ImplScaleInterpolate "
"in-between format has palette, should not "
"happen (!)");
- for (sal_Int32 nX = 0; nX < nNewWidth; nX++)
+ if (1 == nHeight)
{
- if (1 == nHeight)
+ for (sal_Int32 nX = 0; nX < nNewWidth; nX++)
{
BitmapColor aCol0 = pReadAcc->GetPixel(0, nX);
@@ -174,7 +163,25 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const
pWriteAcc->SetPixel(nY, nX, aCol0);
}
}
- else
+ }
+ else
+ {
+ const sal_Int32 nNewHeight1 = nNewHeight - 1;
+ const sal_Int32 nHeight1 = pReadAcc->Height() - 1;
+ const double fRevScaleY = static_cast<double>(nHeight1) / nNewHeight1;
+
+ std::unique_ptr<sal_Int32[]> pLutInt(new sal_Int32[nNewHeight]);
+ std::unique_ptr<sal_Int32[]> pLutFrac(new sal_Int32[nNewHeight]);
+
+ for (sal_Int32 nY = 0, nTemp = nHeight - 2; nY < nNewHeight; nY++)
+ {
+ double fTemp = nY * fRevScaleY;
+ pLutInt[nY] = MinMax(static_cast<sal_Int32>(fTemp), 0, nTemp);
+ fTemp -= pLutInt[nY];
+ pLutFrac[nY] = static_cast<sal_Int32>(fTemp * 1024.);
+ }
+
+ for (sal_Int32 nX = 0; nX < nNewWidth; nX++)
{
for (sal_Int32 nY = 0; nY < nNewHeight; nY++)
{