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 sal_Int16 nRed;
28 sal_Int16 nGreen;
29 sal_Int16 nBlue;
30
31public:
33 : nRed(0)
34 , nGreen(0)
35 , nBlue(0)
36 {
37 }
38
40 : nRed(rColor.GetRed() << 5)
41 , nGreen(rColor.GetGreen() << 5)
42 , nBlue(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() const;
55};
56
57inline void ImpErrorQuad::operator=(const BitmapColor& rColor)
58{
59 nRed = rColor.GetRed() << 5;
60 nGreen = rColor.GetGreen() << 5;
61 nBlue = rColor.GetBlue() << 5;
62}
63
65{
66 nRed -= rColor.GetRed() << 5;
67 nGreen -= rColor.GetGreen() << 5;
68 nBlue -= rColor.GetBlue() << 5;
69
70 return *this;
71}
72
74{
75 nRed += rErrQuad.nRed >> 4;
76 nGreen += rErrQuad.nGreen >> 4;
77 nBlue += rErrQuad.nBlue >> 4;
78}
79
81{
82 nRed += rErrQuad.nRed * 3L >> 4;
83 nGreen += rErrQuad.nGreen * 3L >> 4;
84 nBlue += rErrQuad.nBlue * 3L >> 4;
85}
86
88{
89 nRed += rErrQuad.nRed * 5L >> 4;
90 nGreen += rErrQuad.nGreen * 5L >> 4;
91 nBlue += rErrQuad.nBlue * 5L >> 4;
92}
93
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, 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);
106}
107
108#endif // INCLUDED_VCL_INC_IMPOCTREE_HXX
109
110/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
sal_Int16 nGreen
Definition: impoctree.hxx:28
void ImplAddColorError7(const ImpErrorQuad &rErrQuad)
Definition: impoctree.hxx:94
ImpErrorQuad & operator-=(const BitmapColor &rColor)
Definition: impoctree.hxx:64
ImpErrorQuad(const BitmapColor &rColor)
Definition: impoctree.hxx:39
BitmapColor ImplGetColor() const
Definition: impoctree.hxx:101
void ImplAddColorError5(const ImpErrorQuad &rErrQuad)
Definition: impoctree.hxx:87
sal_Int16 nRed
Definition: impoctree.hxx:27
void ImplAddColorError3(const ImpErrorQuad &rErrQuad)
Definition: impoctree.hxx:80
void ImplAddColorError1(const ImpErrorQuad &rErrQuad)
Definition: impoctree.hxx:73
sal_Int16 nBlue
Definition: impoctree.hxx:29
void operator=(const BitmapColor &rColor)
Definition: impoctree.hxx:57