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 <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
))
48 if (pReadAccess
->GetPixelFromData(pScanlineRead
, x
) != pReadAccess
->GetPixelFromData(pScanlineRead
, nWidth
- x
- 1))
52 if (pReadAccess
->GetPixelFromData(pScanlineRead
, x
) != pReadAccess
->GetPixelFromData(pScanlineRead2
, nWidth
- x
- 1))
61 for (tools::Long y
= 0; y
< nHeightHalf
; ++y
)
63 if (pReadAccess
->GetPixel(y
, nWidthHalf
) != pReadAccess
->GetPixel(nHeight
- y
- 1, nWidthHalf
))
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))
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */