LibreOffice Module vcl (master) 1
pixel.cxx
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#include <vcl/metaact.hxx>
21#include <vcl/virdev.hxx>
22
23#include <drawmode.hxx>
24#include <salgdi.hxx>
25
26#include <cassert>
27
29{
30 Color aColor;
31
33 {
34 assert(mpGraphics);
36 const_cast<OutputDevice*>(this)->InitClipRegion();
37
38 if (!mbOutputClipped)
39 {
40 const tools::Long nX = ImplLogicXToDevicePixel(rPoint.X());
41 const tools::Long nY = ImplLogicYToDevicePixel(rPoint.Y());
42 aColor = mpGraphics->GetPixel(nX, nY, *this);
43
44 if (mpAlphaVDev)
45 {
46 Color aAlphaColor = mpAlphaVDev->GetPixel(rPoint);
47 aColor.SetAlpha(aAlphaColor.GetBlue());
48 }
49 }
50 }
51 return aColor;
52}
53
55{
57
58 if ( mpMetaFile )
60
62 return;
63
64 Point aPt = ImplLogicToDevicePixel( rPt );
65
66 if ( !mpGraphics && !AcquireGraphics() )
67 return;
68 assert(mpGraphics);
69
70 if ( mbInitClipRegion )
72
73 if ( mbOutputClipped )
74 return;
75
76 if ( mbInitLineColor )
78
79 mpGraphics->DrawPixel( aPt.X(), aPt.Y(), *this );
80
81 if( mpAlphaVDev )
82 mpAlphaVDev->DrawPixel( rPt );
83}
84
85void OutputDevice::DrawPixel( const Point& rPt, const Color& rColor )
86{
88
89 Color aColor = vcl::drawmode::GetLineColor(rColor, GetDrawMode(), GetSettings().GetStyleSettings());
90
91 if ( mpMetaFile )
92 mpMetaFile->AddAction( new MetaPixelAction( rPt, aColor ) );
93
95 return;
96
97 Point aPt = ImplLogicToDevicePixel( rPt );
98
99 if ( !mpGraphics && !AcquireGraphics() )
100 return;
101 assert(mpGraphics);
102
103 if ( mbInitClipRegion )
105
106 if ( mbOutputClipped )
107 return;
108
109 mpGraphics->DrawPixel( aPt.X(), aPt.Y(), aColor, *this );
110
111 if (mpAlphaVDev)
112 {
113 Color aAlphaColor(rColor.GetAlpha(), rColor.GetAlpha(), rColor.GetAlpha());
114 mpAlphaVDev->DrawPixel(rPt, aAlphaColor);
115 }
116}
117
118/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 GetBlue() const
sal_uInt8 GetAlpha() const
void SetAlpha(sal_uInt8 nAlpha)
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:585
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
virtual void InitClipRegion()
SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel(tools::Long nY) const
Convert a logical Y coordinate to a device pixel's Y coordinate.
Definition: map.cxx:271
SAL_DLLPRIVATE bool is_double_buffered_window() const
SAL_DLLPRIVATE void InitLineColor()
Definition: line.cxx:85
bool mbOutputClipped
Definition: outdev.hxx:245
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel(const tools::Rectangle &rLogicRect) const
Convert a logical rectangle to a rectangle in physical device pixel units.
Definition: map.cxx:334
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
Definition: outdev.cxx:708
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:185
bool mbInitLineColor
Definition: outdev.hxx:248
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:182
void DrawPixel(const Point &rPt)
Definition: pixel.cxx:54
bool mbInitClipRegion
Definition: outdev.hxx:252
Color GetPixel(const Point &rPt) const
Definition: pixel.cxx:28
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:481
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:196
DrawModeFlags GetDrawMode() const
Definition: outdev.hxx:487
const AllSettings & GetSettings() const
Definition: outdev.hxx:288
bool mbLineColor
Definition: outdev.hxx:246
SAL_DLLPRIVATE tools::Long ImplLogicXToDevicePixel(tools::Long nX) const
Convert a logical X coordinate to a device pixel's X coordinate.
Definition: map.cxx:262
constexpr tools::Long Y() const
constexpr tools::Long X() const
void DrawPixel(tools::Long nX, tools::Long nY, const OutputDevice &rOutDev)
Color GetPixel(tools::Long nX, tools::Long nY, const OutputDevice &rOutDev)
long Long
Color GetLineColor(Color const &rColor, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
Definition: drawmode.cxx:30