1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <tools/degree.hxx>
23 #include <vcl/dllapi.h>
24 #include <vcl/bitmap.hxx>
26 enum class GraphicDrawMode
34 class VCL_DLLPUBLIC GraphicAttr
38 tools::Long mnLeftCrop
;
39 tools::Long mnTopCrop
;
40 tools::Long mnRightCrop
;
41 tools::Long mnBottomCrop
;
42 BmpMirrorFlags mnMirrFlags
;
43 GraphicDrawMode meDrawMode
;
60 , mnMirrFlags(BmpMirrorFlags::NONE
)
61 , meDrawMode(GraphicDrawMode::Standard
)
73 bool operator==(const GraphicAttr
& rAttr
) const
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
;
85 bool operator!=(const GraphicAttr
& rAttr
) const { return !(*this == rAttr
); }
87 void SetDrawMode(GraphicDrawMode eDrawMode
) { meDrawMode
= eDrawMode
; }
88 GraphicDrawMode
GetDrawMode() const { return meDrawMode
; }
90 void SetMirrorFlags(BmpMirrorFlags nMirrFlags
) { mnMirrFlags
= nMirrFlags
; }
91 BmpMirrorFlags
GetMirrorFlags() const { return mnMirrFlags
; }
93 void SetCrop(tools::Long nLeft_100TH_MM
, tools::Long nTop_100TH_MM
, tools::Long nRight_100TH_MM
,
94 tools::Long nBottom_100TH_MM
)
96 mnLeftCrop
= nLeft_100TH_MM
;
97 mnTopCrop
= nTop_100TH_MM
;
98 mnRightCrop
= nRight_100TH_MM
;
99 mnBottomCrop
= nBottom_100TH_MM
;
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
; }
106 void SetRotation(Degree10 nRotate10
) { mnRotate10
= nRotate10
; }
107 Degree10
GetRotation() const { return mnRotate10
; }
109 void SetLuminance(short nLuminancePercent
) { mnLumPercent
= nLuminancePercent
; }
110 short GetLuminance() const { return mnLumPercent
; }
112 void SetContrast(short nContrastPercent
) { mnContPercent
= nContrastPercent
; }
113 short GetContrast() const { return mnContPercent
; }
115 void SetChannelR(short nChannelRPercent
) { mnRPercent
= nChannelRPercent
; }
116 short GetChannelR() const { return mnRPercent
; }
118 void SetChannelG(short nChannelGPercent
) { mnGPercent
= nChannelGPercent
; }
119 short GetChannelG() const { return mnGPercent
; }
121 void SetChannelB(short nChannelBPercent
) { mnBPercent
= nChannelBPercent
; }
122 short GetChannelB() const { return mnBPercent
; }
124 void SetGamma(double fGamma
) { mfGamma
= fGamma
; }
125 double GetGamma() const { return mfGamma
; }
127 void SetInvert(bool bInvert
) { mbInvert
= bInvert
; }
128 bool IsInvert() const { return mbInvert
; }
130 void SetAlpha(sal_uInt8 cAlpha
) { mcAlpha
= cAlpha
; }
131 sal_uInt8
GetAlpha() const { return mcAlpha
; }
133 bool IsSpecialDrawMode() const { return (meDrawMode
!= GraphicDrawMode::Standard
); }
134 bool IsMirrored() const { return mnMirrFlags
!= BmpMirrorFlags::NONE
; }
135 bool IsCropped() const
137 return (mnLeftCrop
!= 0 || mnTopCrop
!= 0 || mnRightCrop
!= 0 || mnBottomCrop
!= 0);
139 bool IsRotated() const { return ((mnRotate10
% 3600_deg10
) != 0_deg10
); }
140 bool IsTransparent() const { return (mcAlpha
< 255); }
141 bool IsAdjusted() const
143 return (mnLumPercent
!= 0 || mnContPercent
!= 0 || mnRPercent
!= 0 || mnGPercent
!= 0
144 || mnBPercent
!= 0 || mfGamma
!= 1.0 || mbInvert
);
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */