Bump for 3.6-28
[LibreOffice.git] / cppcanvas / source / wrapper / implbitmap.cxx
blobf18cb6aaddafd59704f5860c3504c934e6c61784
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "implbitmap.hxx"
31 #include "implbitmapcanvas.hxx"
33 #include <basegfx/matrix/b2dhommatrix.hxx>
34 #include <canvas/canvastools.hxx>
37 using namespace ::com::sun::star;
39 namespace cppcanvas
42 namespace internal
45 ImplBitmap::ImplBitmap( const CanvasSharedPtr& rParentCanvas,
46 const uno::Reference< rendering::XBitmap >& rBitmap ) :
47 CanvasGraphicHelper( rParentCanvas ),
48 mxBitmap( rBitmap ),
49 mpBitmapCanvas()
51 OSL_ENSURE( mxBitmap.is(), "ImplBitmap::ImplBitmap: no valid bitmap" );
53 uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( rBitmap,
54 uno::UNO_QUERY );
55 if( xBitmapCanvas.is() )
56 mpBitmapCanvas.reset( new ImplBitmapCanvas(
57 uno::Reference< rendering::XBitmapCanvas >(rBitmap,
58 uno::UNO_QUERY) ) );
61 ImplBitmap::~ImplBitmap()
65 bool ImplBitmap::draw() const
67 CanvasSharedPtr pCanvas( getCanvas() );
69 OSL_ENSURE( pCanvas.get() != NULL &&
70 pCanvas->getUNOCanvas().is(),
71 "ImplBitmap::draw: invalid canvas" );
73 if( pCanvas.get() == NULL ||
74 !pCanvas->getUNOCanvas().is() )
76 return false;
79 // TODO(P1): implement caching
80 pCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
81 pCanvas->getViewState(),
82 getRenderState() );
84 return true;
87 bool ImplBitmap::drawAlphaModulated( double nAlphaModulation ) const
89 CanvasSharedPtr pCanvas( getCanvas() );
91 OSL_ENSURE( pCanvas.get() != NULL &&
92 pCanvas->getUNOCanvas().is(),
93 "ImplBitmap::drawAlphaModulated(): invalid canvas" );
95 if( pCanvas.get() == NULL ||
96 !pCanvas->getUNOCanvas().is() )
98 return false;
101 rendering::RenderState aLocalState( getRenderState() );
102 uno::Sequence<rendering::ARGBColor> aCol(1);
103 aCol[0] = rendering::ARGBColor( nAlphaModulation, 1.0, 1.0, 1.0 );
104 aLocalState.DeviceColor =
105 pCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace()->convertFromARGB(aCol);
107 // TODO(P1): implement caching
108 pCanvas->getUNOCanvas()->drawBitmapModulated( mxBitmap,
109 pCanvas->getViewState(),
110 aLocalState );
112 return true;
115 BitmapCanvasSharedPtr ImplBitmap::getBitmapCanvas() const
117 return mpBitmapCanvas;
120 uno::Reference< rendering::XBitmap > ImplBitmap::getUNOBitmap() const
122 return mxBitmap;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */