/src/libreoffice/vcl/inc/bitmap/impoctree.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <vcl/BitmapColor.hxx> |
23 | | |
24 | | class ImpErrorQuad |
25 | | { |
26 | | sal_Int16 nRed; |
27 | | sal_Int16 nGreen; |
28 | | sal_Int16 nBlue; |
29 | | |
30 | | public: |
31 | | ImpErrorQuad() |
32 | 310k | : nRed(0) |
33 | 310k | , nGreen(0) |
34 | 310k | , nBlue(0) |
35 | 310k | { |
36 | 310k | } |
37 | | |
38 | | ImpErrorQuad(const BitmapColor& rColor) |
39 | 31.3M | : nRed(rColor.GetRed() << 5) |
40 | 31.3M | , nGreen(rColor.GetGreen() << 5) |
41 | 31.3M | , nBlue(rColor.GetBlue() << 5) |
42 | 31.3M | { |
43 | 31.3M | } |
44 | | |
45 | | inline void operator=(const BitmapColor& rColor); |
46 | | inline ImpErrorQuad& operator-=(const BitmapColor& rColor); |
47 | | |
48 | | inline void ImplAddColorError1(const ImpErrorQuad& rErrQuad); |
49 | | inline void ImplAddColorError3(const ImpErrorQuad& rErrQuad); |
50 | | inline void ImplAddColorError5(const ImpErrorQuad& rErrQuad); |
51 | | inline void ImplAddColorError7(const ImpErrorQuad& rErrQuad); |
52 | | |
53 | | inline BitmapColor ImplGetColor() const; |
54 | | }; |
55 | | |
56 | | inline void ImpErrorQuad::operator=(const BitmapColor& rColor) |
57 | 31.8M | { |
58 | 31.8M | nRed = rColor.GetRed() << 5; |
59 | 31.8M | nGreen = rColor.GetGreen() << 5; |
60 | 31.8M | nBlue = rColor.GetBlue() << 5; |
61 | 31.8M | } |
62 | | |
63 | | inline ImpErrorQuad& ImpErrorQuad::operator-=(const BitmapColor& rColor) |
64 | 31.3M | { |
65 | 31.3M | nRed -= rColor.GetRed() << 5; |
66 | 31.3M | nGreen -= rColor.GetGreen() << 5; |
67 | 31.3M | nBlue -= rColor.GetBlue() << 5; |
68 | | |
69 | 31.3M | return *this; |
70 | 31.3M | } |
71 | | |
72 | | inline void ImpErrorQuad::ImplAddColorError1(const ImpErrorQuad& rErrQuad) |
73 | 31.3M | { |
74 | 31.3M | nRed += rErrQuad.nRed >> 4; |
75 | 31.3M | nGreen += rErrQuad.nGreen >> 4; |
76 | 31.3M | nBlue += rErrQuad.nBlue >> 4; |
77 | 31.3M | } |
78 | | |
79 | | inline void ImpErrorQuad::ImplAddColorError3(const ImpErrorQuad& rErrQuad) |
80 | 31.3M | { |
81 | 31.3M | nRed += rErrQuad.nRed * 3L >> 4; |
82 | 31.3M | nGreen += rErrQuad.nGreen * 3L >> 4; |
83 | 31.3M | nBlue += rErrQuad.nBlue * 3L >> 4; |
84 | 31.3M | } |
85 | | |
86 | | inline void ImpErrorQuad::ImplAddColorError5(const ImpErrorQuad& rErrQuad) |
87 | 31.3M | { |
88 | 31.3M | nRed += rErrQuad.nRed * 5L >> 4; |
89 | 31.3M | nGreen += rErrQuad.nGreen * 5L >> 4; |
90 | 31.3M | nBlue += rErrQuad.nBlue * 5L >> 4; |
91 | 31.3M | } |
92 | | |
93 | | inline void ImpErrorQuad::ImplAddColorError7(const ImpErrorQuad& rErrQuad) |
94 | 31.3M | { |
95 | 31.3M | nRed += rErrQuad.nRed * 7L >> 4; |
96 | 31.3M | nGreen += rErrQuad.nGreen * 7L >> 4; |
97 | 31.3M | nBlue += rErrQuad.nBlue * 7L >> 4; |
98 | 31.3M | } |
99 | | |
100 | | inline BitmapColor ImpErrorQuad::ImplGetColor() const |
101 | 31.8M | { |
102 | 31.8M | return BitmapColor(std::clamp(nRed, sal_Int16(0), sal_Int16(8160)) >> 5, |
103 | 31.8M | std::clamp(nGreen, sal_Int16(0), sal_Int16(8160)) >> 5, |
104 | 31.8M | std::clamp(nBlue, sal_Int16(0), sal_Int16(8160)) >> 5); |
105 | 31.8M | } |
106 | | |
107 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |