LibreOffice Module vcl (master)  1
impoctree.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_INC_IMPOCTREE_HXX
21 #define INCLUDED_VCL_INC_IMPOCTREE_HXX
22 
23 #include "Octree.hxx"
24 
26 {
27  long nRed;
28  long nGreen;
29  long nBlue;
30 
31 public:
33  : nRed(0)
34  , nGreen(0)
35  , nBlue(0)
36  {
37  }
38 
39  ImpErrorQuad(const BitmapColor& rColor)
40  : nRed(long(rColor.GetRed()) << 5)
41  , nGreen(long(rColor.GetGreen()) << 5)
42  , nBlue(long(rColor.GetBlue()) << 5)
43  {
44  }
45 
46  inline void operator=(const BitmapColor& rColor);
47  inline ImpErrorQuad& operator-=(const BitmapColor& rColor);
48 
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);
53 
54  inline BitmapColor ImplGetColor();
55 };
56 
57 inline void ImpErrorQuad::operator=(const BitmapColor& rColor)
58 {
59  nRed = long(rColor.GetRed()) << 5;
60  nGreen = long(rColor.GetGreen()) << 5;
61  nBlue = long(rColor.GetBlue()) << 5;
62 }
63 
65 {
66  nRed -= long(rColor.GetRed()) << 5;
67  nGreen -= long(rColor.GetGreen()) << 5;
68  nBlue -= long(rColor.GetBlue()) << 5;
69 
70  return *this;
71 }
72 
73 inline void ImpErrorQuad::ImplAddColorError1(const ImpErrorQuad& rErrQuad)
74 {
75  nRed += rErrQuad.nRed >> 4;
76  nGreen += rErrQuad.nGreen >> 4;
77  nBlue += rErrQuad.nBlue >> 4;
78 }
79 
80 inline void ImpErrorQuad::ImplAddColorError3(const ImpErrorQuad& rErrQuad)
81 {
82  nRed += rErrQuad.nRed * 3L >> 4;
83  nGreen += rErrQuad.nGreen * 3L >> 4;
84  nBlue += rErrQuad.nBlue * 3L >> 4;
85 }
86 
87 inline void ImpErrorQuad::ImplAddColorError5(const ImpErrorQuad& rErrQuad)
88 {
89  nRed += rErrQuad.nRed * 5L >> 4;
90  nGreen += rErrQuad.nGreen * 5L >> 4;
91  nBlue += rErrQuad.nBlue * 5L >> 4;
92 }
93 
94 inline void ImpErrorQuad::ImplAddColorError7(const ImpErrorQuad& rErrQuad)
95 {
96  nRed += rErrQuad.nRed * 7L >> 4;
97  nGreen += rErrQuad.nGreen * 7L >> 4;
98  nBlue += rErrQuad.nBlue * 7L >> 4;
99 }
100 
102 {
103  return BitmapColor(std::clamp(nRed, 0L, 8160L) >> 5, std::clamp(nGreen, 0L, 8160L) >> 5,
104  std::clamp(nBlue, 0L, 8160L) >> 5);
105 }
106 
107 #endif // INCLUDED_VCL_INC_IMPOCTREE_HXX
108 
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 GetRed() const
ImpErrorQuad & operator-=(const BitmapColor &rColor)
Definition: impoctree.hxx:64
ImpErrorQuad(const BitmapColor &rColor)
Definition: impoctree.hxx:39
void ImplAddColorError1(const ImpErrorQuad &rErrQuad)
Definition: impoctree.hxx:73
void operator=(const BitmapColor &rColor)
Definition: impoctree.hxx:57
sal_uInt8 GetBlue() const
BitmapColor ImplGetColor()
Definition: impoctree.hxx:101
void ImplAddColorError5(const ImpErrorQuad &rErrQuad)
Definition: impoctree.hxx:87
void ImplAddColorError3(const ImpErrorQuad &rErrQuad)
Definition: impoctree.hxx:80
sal_uInt8 GetGreen() const
void ImplAddColorError7(const ImpErrorQuad &rErrQuad)
Definition: impoctree.hxx:94