/src/libreoffice/include/vcl/GraphicAttributes.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 <tools/degree.hxx> |
23 | | #include <vcl/dllapi.h> |
24 | | #include <vcl/bitmap.hxx> |
25 | | |
26 | | // Represents css::drawing::ColorMode |
27 | | enum class GraphicDrawMode |
28 | | { |
29 | | Standard = 0, |
30 | | Greys = 1, |
31 | | Mono = 2, |
32 | | Watermark = 3 |
33 | | }; |
34 | | |
35 | | class VCL_DLLPUBLIC GraphicAttr |
36 | | { |
37 | | private: |
38 | | double mfGamma; |
39 | | tools::Long mnLeftCrop; |
40 | | tools::Long mnTopCrop; |
41 | | tools::Long mnRightCrop; |
42 | | tools::Long mnBottomCrop; |
43 | | BmpMirrorFlags mnMirrFlags; |
44 | | GraphicDrawMode meDrawMode; |
45 | | Degree10 mnRotate10; |
46 | | short mnContPercent; |
47 | | short mnLumPercent; |
48 | | short mnRPercent; |
49 | | short mnGPercent; |
50 | | short mnBPercent; |
51 | | sal_uInt8 mcAlpha; |
52 | | bool mbInvert; |
53 | | |
54 | | public: |
55 | | GraphicAttr() |
56 | 402k | : mfGamma(1.0) |
57 | 402k | , mnLeftCrop(0) |
58 | 402k | , mnTopCrop(0) |
59 | 402k | , mnRightCrop(0) |
60 | 402k | , mnBottomCrop(0) |
61 | 402k | , mnMirrFlags(BmpMirrorFlags::NONE) |
62 | 402k | , meDrawMode(GraphicDrawMode::Standard) |
63 | 402k | , mnRotate10(0) |
64 | 402k | , mnContPercent(0) |
65 | 402k | , mnLumPercent(0) |
66 | 402k | , mnRPercent(0) |
67 | 402k | , mnGPercent(0) |
68 | 402k | , mnBPercent(0) |
69 | 402k | , mcAlpha(255) |
70 | 402k | , mbInvert(false) |
71 | 402k | { |
72 | 402k | } |
73 | | |
74 | | bool operator==(const GraphicAttr& rAttr) const |
75 | 36.4k | { |
76 | 36.4k | return mfGamma == rAttr.mfGamma && mnMirrFlags == rAttr.mnMirrFlags |
77 | 36.4k | && mnLeftCrop == rAttr.mnLeftCrop && mnTopCrop == rAttr.mnTopCrop |
78 | 36.4k | && mnRightCrop == rAttr.mnRightCrop && mnBottomCrop == rAttr.mnBottomCrop |
79 | 36.4k | && mnRotate10 == rAttr.mnRotate10 && mnContPercent == rAttr.mnContPercent |
80 | 36.4k | && mnLumPercent == rAttr.mnLumPercent && mnRPercent == rAttr.mnRPercent |
81 | 36.4k | && mnGPercent == rAttr.mnGPercent && mnBPercent == rAttr.mnBPercent |
82 | 36.4k | && mbInvert == rAttr.mbInvert && mcAlpha == rAttr.mcAlpha |
83 | 36.4k | && meDrawMode == rAttr.meDrawMode; |
84 | 36.4k | } |
85 | | |
86 | 0 | bool operator!=(const GraphicAttr& rAttr) const { return !(*this == rAttr); } |
87 | | |
88 | 386 | void SetDrawMode(GraphicDrawMode eDrawMode) { meDrawMode = eDrawMode; } |
89 | 374 | GraphicDrawMode GetDrawMode() const { return meDrawMode; } |
90 | | |
91 | 638 | void SetMirrorFlags(BmpMirrorFlags nMirrFlags) { mnMirrFlags = nMirrFlags; } |
92 | 528 | BmpMirrorFlags GetMirrorFlags() const { return mnMirrFlags; } |
93 | | |
94 | | void SetCrop(tools::Long nLeft_100TH_MM, tools::Long nTop_100TH_MM, tools::Long nRight_100TH_MM, |
95 | | tools::Long nBottom_100TH_MM) |
96 | 760 | { |
97 | 760 | mnLeftCrop = nLeft_100TH_MM; |
98 | 760 | mnTopCrop = nTop_100TH_MM; |
99 | 760 | mnRightCrop = nRight_100TH_MM; |
100 | 760 | mnBottomCrop = nBottom_100TH_MM; |
101 | 760 | } |
102 | 0 | tools::Long GetLeftCrop() const { return mnLeftCrop; } |
103 | 0 | tools::Long GetTopCrop() const { return mnTopCrop; } |
104 | 0 | tools::Long GetRightCrop() const { return mnRightCrop; } |
105 | 0 | tools::Long GetBottomCrop() const { return mnBottomCrop; } |
106 | | |
107 | 760 | void SetRotation(Degree10 nRotate10) { mnRotate10 = nRotate10; } |
108 | 0 | Degree10 GetRotation() const { return mnRotate10; } |
109 | | |
110 | 386 | void SetLuminance(short nLuminancePercent) { mnLumPercent = nLuminancePercent; } |
111 | 0 | short GetLuminance() const { return mnLumPercent; } |
112 | | |
113 | 386 | void SetContrast(short nContrastPercent) { mnContPercent = nContrastPercent; } |
114 | 0 | short GetContrast() const { return mnContPercent; } |
115 | | |
116 | 386 | void SetChannelR(short nChannelRPercent) { mnRPercent = nChannelRPercent; } |
117 | 0 | short GetChannelR() const { return mnRPercent; } |
118 | | |
119 | 386 | void SetChannelG(short nChannelGPercent) { mnGPercent = nChannelGPercent; } |
120 | 0 | short GetChannelG() const { return mnGPercent; } |
121 | | |
122 | 386 | void SetChannelB(short nChannelBPercent) { mnBPercent = nChannelBPercent; } |
123 | 0 | short GetChannelB() const { return mnBPercent; } |
124 | | |
125 | 386 | void SetGamma(double fGamma) { mfGamma = fGamma; } |
126 | 0 | double GetGamma() const { return mfGamma; } |
127 | | |
128 | 386 | void SetInvert(bool bInvert) { mbInvert = bInvert; } |
129 | 0 | bool IsInvert() const { return mbInvert; } |
130 | | |
131 | 814 | void SetAlpha(sal_uInt8 cAlpha) { mcAlpha = cAlpha; } |
132 | 1.00k | sal_uInt8 GetAlpha() const { return mcAlpha; } |
133 | | |
134 | 13 | bool IsSpecialDrawMode() const { return (meDrawMode != GraphicDrawMode::Standard); } |
135 | 374 | bool IsMirrored() const { return mnMirrFlags != BmpMirrorFlags::NONE; } |
136 | | bool IsCropped() const |
137 | 25 | { |
138 | 25 | return (mnLeftCrop != 0 || mnTopCrop != 0 || mnRightCrop != 0 || mnBottomCrop != 0); |
139 | 25 | } |
140 | 0 | bool IsRotated() const { return ((mnRotate10 % 3600_deg10) != 0_deg10); } |
141 | 0 | bool IsTransparent() const { return (mcAlpha < 255); } |
142 | | bool IsAdjusted() const |
143 | 387 | { |
144 | 387 | return (mnLumPercent != 0 || mnContPercent != 0 || mnRPercent != 0 || mnGPercent != 0 |
145 | 387 | || mnBPercent != 0 || mfGamma != 1.0 || mbInvert); |
146 | 387 | } |
147 | | }; |
148 | | |
149 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |