1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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
))
44 if (pReadAccess
->GetPixel(y
, x
) != pReadAccess
->GetPixel(y
, nWidth
- x
- 1))
48 if (pReadAccess
->GetPixel(y
, x
) != pReadAccess
->GetPixel(nHeight
- y
- 1, nWidth
- x
- 1))
57 for (long y
= 0; y
< nHeightHalf
; ++y
)
59 if (pReadAccess
->GetPixel(y
, nWidthHalf
) != pReadAccess
->GetPixel(nHeight
- y
- 1, nWidthHalf
))
68 for (long x
= 0; x
< nWidthHalf
; ++x
)
70 if (pReadAccess
->GetPixel(nHeightHalf
, x
) != pReadAccess
->GetPixel(nHeightHalf
, nWidth
- x
- 1))
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */