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
const * 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 Scanline pScanlineRead
= pReadAccess
->GetScanline( y
);
39 Scanline pScanlineRead2
= pReadAccess
->GetScanline( nHeight
- y
- 1 );
40 for (long x
= 0; x
< nWidthHalf
; ++x
)
42 if (pReadAccess
->GetPixelFromData(pScanlineRead
, x
) != pReadAccess
->GetPixelFromData(pScanlineRead2
, x
))
46 if (pReadAccess
->GetPixelFromData(pScanlineRead
, x
) != pReadAccess
->GetPixelFromData(pScanlineRead
, nWidth
- x
- 1))
50 if (pReadAccess
->GetPixelFromData(pScanlineRead
, x
) != pReadAccess
->GetPixelFromData(pScanlineRead2
, nWidth
- x
- 1))
59 for (long y
= 0; y
< nHeightHalf
; ++y
)
61 if (pReadAccess
->GetPixel(y
, nWidthHalf
) != pReadAccess
->GetPixel(nHeight
- y
- 1, nWidthHalf
))
70 Scanline pScanlineRead
= pReadAccess
->GetScanline( nHeightHalf
);
71 for (long x
= 0; x
< nWidthHalf
; ++x
)
73 if (pReadAccess
->GetPixelFromData(pScanlineRead
, x
) != pReadAccess
->GetPixelFromData(pScanlineRead
, nWidth
- x
- 1))
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */