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 .
20 #include <sal/log.hxx>
22 #include <vcl/metaact.hxx>
23 #include <vcl/print.hxx>
24 #include <vcl/printer/Options.hxx>
29 void Printer::DrawGradientEx( OutputDevice
* pOut
, const tools::Rectangle
& rRect
, const Gradient
& rGradient
)
31 const vcl::printer::Options
& rPrinterOptions
= GetPrinterOptions();
33 if( rPrinterOptions
.IsReduceGradients() )
35 if( vcl::printer::GradientMode::Stripes
== rPrinterOptions
.GetReducedGradientMode() )
37 if( !rGradient
.GetSteps() || ( rGradient
.GetSteps() > rPrinterOptions
.GetReducedGradientStepCount() ) )
39 Gradient
aNewGradient( rGradient
);
41 aNewGradient
.SetSteps( rPrinterOptions
.GetReducedGradientStepCount() );
42 pOut
->DrawGradient( rRect
, aNewGradient
);
45 pOut
->DrawGradient( rRect
, rGradient
);
49 const Color
& rStartColor
= rGradient
.GetStartColor();
50 const Color
& rEndColor
= rGradient
.GetEndColor();
51 const tools::Long nR
= ( ( static_cast<tools::Long
>(rStartColor
.GetRed()) * rGradient
.GetStartIntensity() ) / 100 +
52 ( static_cast<tools::Long
>(rEndColor
.GetRed()) * rGradient
.GetEndIntensity() ) / 100 ) >> 1;
53 const tools::Long nG
= ( ( static_cast<tools::Long
>(rStartColor
.GetGreen()) * rGradient
.GetStartIntensity() ) / 100 +
54 ( static_cast<tools::Long
>(rEndColor
.GetGreen()) * rGradient
.GetEndIntensity() ) / 100 ) >> 1;
55 const tools::Long nB
= ( ( static_cast<tools::Long
>(rStartColor
.GetBlue()) * rGradient
.GetStartIntensity() ) / 100 +
56 ( static_cast<tools::Long
>(rEndColor
.GetBlue()) * rGradient
.GetEndIntensity() ) / 100 ) >> 1;
57 const Color
aColor( static_cast<sal_uInt8
>(nR
), static_cast<sal_uInt8
>(nG
), static_cast<sal_uInt8
>(nB
) );
59 pOut
->Push( vcl::PushFlags::LINECOLOR
| vcl::PushFlags::FILLCOLOR
);
60 pOut
->SetLineColor( aColor
);
61 pOut
->SetFillColor( aColor
);
62 pOut
->DrawRect( rRect
);
67 pOut
->DrawGradient( rRect
, rGradient
);
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */