build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / vcl / source / bitmap / BitmapSymmetryCheck.cxx
blobf1a600815f1c9c1cce181f85ed4ba04dd19a79ac
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 <BitmapSymmetryCheck.hxx>
13 BitmapSymmetryCheck::BitmapSymmetryCheck()
16 BitmapSymmetryCheck::~BitmapSymmetryCheck()
19 bool BitmapSymmetryCheck::check(Bitmap& rBitmap)
21 Bitmap::ScopedReadAccess aReadAccess(rBitmap);
22 return checkImpl(aReadAccess.get());
25 bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess* pReadAccess)
27 long nHeight = pReadAccess->Height();
28 long nWidth = pReadAccess->Width();
30 long nHeightHalf = nHeight / 2;
31 long nWidthHalf = nWidth / 2;
33 bool bHeightEven = (nHeight % 2) == 0;
34 bool bWidthEven = (nWidth % 2) == 0;
36 for (long y = 0; y < nHeightHalf; ++y)
38 for (long x = 0; x < nWidthHalf; ++x)
40 if (pReadAccess->GetPixel(y, x) != pReadAccess->GetPixel(nHeight - y - 1, x))
42 return false;
44 if (pReadAccess->GetPixel(y, x) != pReadAccess->GetPixel(y, nWidth - x - 1))
46 return false;
48 if (pReadAccess->GetPixel(y, x) != pReadAccess->GetPixel(nHeight - y - 1, nWidth - x - 1))
50 return false;
55 if (bWidthEven)
57 for (long y = 0; y < nHeightHalf; ++y)
59 if (pReadAccess->GetPixel(y, nWidthHalf) != pReadAccess->GetPixel(nHeight - y - 1, nWidthHalf))
61 return false;
66 if (bHeightEven)
68 for (long x = 0; x < nWidthHalf; ++x)
70 if (pReadAccess->GetPixel(nHeightHalf, x) != pReadAccess->GetPixel(nHeightHalf, nWidth - x - 1))
72 return false;
77 return true;
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */