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 <cassert>
21 
22 #include <vcl/gdimtf.hxx>
23 #include <vcl/metaact.hxx>
24 #include <vcl/outdev.hxx>
25 #include <vcl/virdev.hxx>
26 
27 #include <salgdi.hxx>
28 
29 Color OutputDevice::GetPixel(const Point& rPoint) const
30 {
31  Color aColor;
32 
33  if (mpGraphics || AcquireGraphics())
34  {
35  if (mbInitClipRegion)
36  const_cast<OutputDevice*>(this)->InitClipRegion();
37 
38  if (!mbOutputClipped)
39  {
40  const long nX = ImplLogicXToDevicePixel(rPoint.X());
41  const 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.SetTransparency(aAlphaColor.GetBlue());
48  }
49  }
50  }
51  return aColor;
52 }
53 
54 void OutputDevice::DrawPixel( const Point& rPt )
55 {
56  assert(!is_double_buffered_window());
57 
58  if ( mpMetaFile )
59  mpMetaFile->AddAction( new MetaPointAction( rPt ) );
60 
62  return;
63 
64  Point aPt = ImplLogicToDevicePixel( rPt );
65 
66  if ( !mpGraphics && !AcquireGraphics() )
67  return;
68 
69  if ( mbInitClipRegion )
71 
72  if ( mbOutputClipped )
73  return;
74 
75  if ( mbInitLineColor )
76  InitLineColor();
77 
78  mpGraphics->DrawPixel( aPt.X(), aPt.Y(), this );
79 
80  if( mpAlphaVDev )
81  mpAlphaVDev->DrawPixel( rPt );
82 }
83 
84 void OutputDevice::DrawPixel( const Point& rPt, const Color& rColor )
85 {
86  assert(!is_double_buffered_window());
87 
88  Color aColor = ImplDrawModeToColor( rColor );
89 
90  if ( mpMetaFile )
91  mpMetaFile->AddAction( new MetaPixelAction( rPt, aColor ) );
92 
94  return;
95 
96  Point aPt = ImplLogicToDevicePixel( rPt );
97 
98  if ( !mpGraphics && !AcquireGraphics() )
99  return;
100 
101  if ( mbInitClipRegion )
102  InitClipRegion();
103 
104  if ( mbOutputClipped )
105  return;
106 
107  mpGraphics->DrawPixel( aPt.X(), aPt.Y(), aColor, this );
108 
109  if (mpAlphaVDev)
110  {
111  Color aAlphaColor(rColor.GetTransparency(), rColor.GetTransparency(), rColor.GetTransparency());
112  mpAlphaVDev->DrawPixel(rPt, aAlphaColor);
113  }
114 }
115 
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
Definition: outdev.cxx:657
void SetTransparency(sal_uInt8 nTransparency)
sal_uInt8 GetTransparency() const
bool mbOutputClipped
Definition: outdev.hxx:381
SAL_DLLPRIVATE bool is_double_buffered_window() const
SAL_DLLPRIVATE Color ImplDrawModeToColor(const Color &rColor) const
Definition: transparent.cxx:78
SAL_DLLPRIVATE void InitLineColor()
sal_uInt8 GetBlue() const
SAL_DLLPRIVATE long ImplLogicXToDevicePixel(long nX) const
Convert a logical X coordinate to a device pixel's X coordinate.
Definition: map.cxx:410
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:316
SAL_DLLPRIVATE long ImplLogicYToDevicePixel(long nY) const
Convert a logical Y coordinate to a device pixel's Y coordinate.
Definition: map.cxx:420
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
bool mbInitLineColor
Definition: outdev.hxx:384
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
bool mbLineColor
Definition: outdev.hxx:382
void DrawPixel(const Point &rPt)
Definition: pixel.cxx:54
long X() const
void DrawPixel(long nX, long nY, const OutputDevice *pOutDev)
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:331
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:540
Color GetPixel(long nX, long nY, const OutputDevice *pOutDev)
bool mbInitClipRegion
Definition: outdev.hxx:388
virtual void InitClipRegion()
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:504
Color GetPixel(const Point &rPt) const
Definition: pixel.cxx:29
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:589
long Y() const
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:319