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