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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_IMPOCTREE_HXX
21 #define INCLUDED_VCL_INC_IMPOCTREE_HXX
39 ImpErrorQuad(const BitmapColor
& rColor
)
40 : nRed(rColor
.GetRed() << 5)
41 , nGreen(rColor
.GetGreen() << 5)
42 , nBlue(rColor
.GetBlue() << 5)
46 inline void operator=(const BitmapColor
& rColor
);
47 inline ImpErrorQuad
& operator-=(const BitmapColor
& rColor
);
49 inline void ImplAddColorError1(const ImpErrorQuad
& rErrQuad
);
50 inline void ImplAddColorError3(const ImpErrorQuad
& rErrQuad
);
51 inline void ImplAddColorError5(const ImpErrorQuad
& rErrQuad
);
52 inline void ImplAddColorError7(const ImpErrorQuad
& rErrQuad
);
54 inline BitmapColor
ImplGetColor();
57 inline void ImpErrorQuad::operator=(const BitmapColor
& rColor
)
59 nRed
= rColor
.GetRed() << 5;
60 nGreen
= rColor
.GetGreen() << 5;
61 nBlue
= rColor
.GetBlue() << 5;
64 inline ImpErrorQuad
& ImpErrorQuad::operator-=(const BitmapColor
& rColor
)
66 nRed
-= rColor
.GetRed() << 5;
67 nGreen
-= rColor
.GetGreen() << 5;
68 nBlue
-= rColor
.GetBlue() << 5;
73 inline void ImpErrorQuad::ImplAddColorError1(const ImpErrorQuad
& rErrQuad
)
75 nRed
+= rErrQuad
.nRed
>> 4;
76 nGreen
+= rErrQuad
.nGreen
>> 4;
77 nBlue
+= rErrQuad
.nBlue
>> 4;
80 inline void ImpErrorQuad::ImplAddColorError3(const ImpErrorQuad
& rErrQuad
)
82 nRed
+= rErrQuad
.nRed
* 3L >> 4;
83 nGreen
+= rErrQuad
.nGreen
* 3L >> 4;
84 nBlue
+= rErrQuad
.nBlue
* 3L >> 4;
87 inline void ImpErrorQuad::ImplAddColorError5(const ImpErrorQuad
& rErrQuad
)
89 nRed
+= rErrQuad
.nRed
* 5L >> 4;
90 nGreen
+= rErrQuad
.nGreen
* 5L >> 4;
91 nBlue
+= rErrQuad
.nBlue
* 5L >> 4;
94 inline void ImpErrorQuad::ImplAddColorError7(const ImpErrorQuad
& rErrQuad
)
96 nRed
+= rErrQuad
.nRed
* 7L >> 4;
97 nGreen
+= rErrQuad
.nGreen
* 7L >> 4;
98 nBlue
+= rErrQuad
.nBlue
* 7L >> 4;
101 inline BitmapColor
ImpErrorQuad::ImplGetColor()
103 return BitmapColor(std::clamp(nRed
, sal_Int16(0), sal_Int16(8160)) >> 5,
104 std::clamp(nGreen
, sal_Int16(0), sal_Int16(8160)) >> 5,
105 std::clamp(nBlue
, sal_Int16(0), sal_Int16(8160)) >> 5);
108 #endif // INCLUDED_VCL_INC_IMPOCTREE_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */