bump product version to 7.2.5.1
[LibreOffice.git] / vcl / source / bitmap / BitmapSymmetryCheck.cxx
blobd2e450c0337df2a287358d51639f226fee71dbf9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #include <vcl/BitmapReadAccess.hxx>
13 #include <BitmapSymmetryCheck.hxx>
15 BitmapSymmetryCheck::BitmapSymmetryCheck()
18 BitmapSymmetryCheck::~BitmapSymmetryCheck()
21 bool BitmapSymmetryCheck::check(Bitmap& rBitmap)
23 Bitmap::ScopedReadAccess aReadAccess(rBitmap);
24 return checkImpl(aReadAccess.get());
27 bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const * pReadAccess)
29 tools::Long nHeight = pReadAccess->Height();
30 tools::Long nWidth = pReadAccess->Width();
32 tools::Long nHeightHalf = nHeight / 2;
33 tools::Long nWidthHalf = nWidth / 2;
35 bool bHeightEven = (nHeight % 2) == 0;
36 bool bWidthEven = (nWidth % 2) == 0;
38 for (tools::Long y = 0; y < nHeightHalf; ++y)
40 Scanline pScanlineRead = pReadAccess->GetScanline( y );
41 Scanline pScanlineRead2 = pReadAccess->GetScanline( nHeight - y - 1 );
42 for (tools::Long x = 0; x < nWidthHalf; ++x)
44 if (pReadAccess->GetPixelFromData(pScanlineRead, x) != pReadAccess->GetPixelFromData(pScanlineRead2, x))
46 return false;
48 if (pReadAccess->GetPixelFromData(pScanlineRead, x) != pReadAccess->GetPixelFromData(pScanlineRead, nWidth - x - 1))
50 return false;
52 if (pReadAccess->GetPixelFromData(pScanlineRead, x) != pReadAccess->GetPixelFromData(pScanlineRead2, nWidth - x - 1))
54 return false;
59 if (bWidthEven)
61 for (tools::Long y = 0; y < nHeightHalf; ++y)
63 if (pReadAccess->GetPixel(y, nWidthHalf) != pReadAccess->GetPixel(nHeight - y - 1, nWidthHalf))
65 return false;
70 if (bHeightEven)
72 Scanline pScanlineRead = pReadAccess->GetScanline( nHeightHalf );
73 for (tools::Long x = 0; x < nWidthHalf; ++x)
75 if (pReadAccess->GetPixelFromData(pScanlineRead, x) != pReadAccess->GetPixelFromData(pScanlineRead, nWidth - x - 1))
77 return false;
82 return true;
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */