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 
26 enum class GraphicDrawMode
27 {
28  Standard = 0,
29  Greys = 1,
30  Mono = 2,
31  Watermark = 3
32 };
33 
35 {
36 private:
37  double mfGamma;
45  short mnLumPercent;
46  short mnRPercent;
47  short mnGPercent;
48  short mnBPercent;
49  bool mbInvert;
52 
53 public:
54  GraphicAttr();
55 
56  bool operator==(const GraphicAttr& rAttr) const;
57  bool operator!=(const GraphicAttr& rAttr) const { return !(*this == rAttr); }
58 
59  void SetDrawMode(GraphicDrawMode eDrawMode) { meDrawMode = eDrawMode; }
60  GraphicDrawMode GetDrawMode() const { return meDrawMode; }
61 
62  void SetMirrorFlags(BmpMirrorFlags nMirrFlags) { mnMirrFlags = nMirrFlags; }
63  BmpMirrorFlags GetMirrorFlags() const { return mnMirrFlags; }
64 
65  void SetCrop(tools::Long nLeft_100TH_MM, tools::Long nTop_100TH_MM, tools::Long nRight_100TH_MM,
66  tools::Long nBottom_100TH_MM)
67  {
68  mnLeftCrop = nLeft_100TH_MM;
69  mnTopCrop = nTop_100TH_MM;
70  mnRightCrop = nRight_100TH_MM;
71  mnBottomCrop = nBottom_100TH_MM;
72  }
73  tools::Long GetLeftCrop() const { return mnLeftCrop; }
74  tools::Long GetTopCrop() const { return mnTopCrop; }
75  tools::Long GetRightCrop() const { return mnRightCrop; }
76  tools::Long GetBottomCrop() const { return mnBottomCrop; }
77 
78  void SetRotation(Degree10 nRotate10) { mnRotate10 = nRotate10; }
79  Degree10 GetRotation() const { return mnRotate10; }
80 
81  void SetLuminance(short nLuminancePercent) { mnLumPercent = nLuminancePercent; }
82  short GetLuminance() const { return mnLumPercent; }
83 
84  void SetContrast(short nContrastPercent) { mnContPercent = nContrastPercent; }
85  short GetContrast() const { return mnContPercent; }
86 
87  void SetChannelR(short nChannelRPercent) { mnRPercent = nChannelRPercent; }
88  short GetChannelR() const { return mnRPercent; }
89 
90  void SetChannelG(short nChannelGPercent) { mnGPercent = nChannelGPercent; }
91  short GetChannelG() const { return mnGPercent; }
92 
93  void SetChannelB(short nChannelBPercent) { mnBPercent = nChannelBPercent; }
94  short GetChannelB() const { return mnBPercent; }
95 
96  void SetGamma(double fGamma) { mfGamma = fGamma; }
97  double GetGamma() const { return mfGamma; }
98 
99  void SetInvert(bool bInvert) { mbInvert = bInvert; }
100  bool IsInvert() const { return mbInvert; }
101 
102  void SetAlpha(sal_uInt8 cAlpha) { mcAlpha = cAlpha; }
103  sal_uInt8 GetAlpha() const { return mcAlpha; }
104 
105  bool IsSpecialDrawMode() const { return (meDrawMode != GraphicDrawMode::Standard); }
106  bool IsMirrored() const { return mnMirrFlags != BmpMirrorFlags::NONE; }
107  bool IsCropped() const
108  {
109  return (mnLeftCrop != 0 || mnTopCrop != 0 || mnRightCrop != 0 || mnBottomCrop != 0);
110  }
111  bool IsRotated() const { return ((mnRotate10 % 3600_deg10) != 0_deg10); }
112  bool IsTransparent() const { return (mcAlpha < 255); }
113  bool IsAdjusted() const
114  {
115  return (mnLumPercent != 0 || mnContPercent != 0 || mnRPercent != 0 || mnGPercent != 0
116  || mnBPercent != 0 || mfGamma != 1.0 || mbInvert);
117  }
118 };
119 
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long GetBottomCrop() const
void SetGamma(double fGamma)
bool IsInvert() const
BmpMirrorFlags GetMirrorFlags() const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void SetInvert(bool bInvert)
long Long
bool IsMirrored() const
void SetMirrorFlags(BmpMirrorFlags nMirrFlags)
tools::Long GetTopCrop() const
GraphicDrawMode GetDrawMode() const
void SetDrawMode(GraphicDrawMode eDrawMode)
sal_uInt8 GetAlpha() const
tools::Long mnLeftCrop
double GetGamma() const
bool IsTransparent() const
short GetChannelR() const
short GetLuminance() const
GraphicDrawMode
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:204
bool IsCropped() const
bool IsSpecialDrawMode() const
void SetAlpha(sal_uInt8 cAlpha)
void SetContrast(short nContrastPercent)
void SetRotation(Degree10 nRotate10)
bool IsRotated() const
tools::Long GetRightCrop() const
GraphicDrawMode meDrawMode
void SetChannelG(short nChannelGPercent)
BmpMirrorFlags
Definition: bitmap.hxx:42
bool IsAdjusted() const
void SetChannelR(short nChannelRPercent)
void SetChannelB(short nChannelBPercent)
short GetContrast() const
tools::Long mnBottomCrop
unsigned char sal_uInt8
BmpMirrorFlags mnMirrFlags
void SetLuminance(short nLuminancePercent)
tools::Long GetLeftCrop() const
tools::Long mnRightCrop
bool operator!=(const GraphicAttr &rAttr) const
tools::Long mnTopCrop
void SetCrop(tools::Long nLeft_100TH_MM, tools::Long nTop_100TH_MM, tools::Long nRight_100TH_MM, tools::Long nBottom_100TH_MM)
short GetChannelG() const
short GetChannelB() const
Degree10 GetRotation() const