1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _VCLCANVAS_CANVASBITMAPHELPER_HXX_ 29*cdf0e10cSrcweir #define _VCLCANVAS_CANVASBITMAPHELPER_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <canvashelper.hxx> 32*cdf0e10cSrcweir #include <canvas/vclwrapper.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include "bitmapbackbuffer.hxx" 37*cdf0e10cSrcweir #include "spritecanvas.hxx" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir namespace vclcanvas 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir /** Helper class for basic canvasbitmap functionality. Extends 43*cdf0e10cSrcweir CanvasHelper with some CanvasBitmap specialities, such as alpha 44*cdf0e10cSrcweir support. 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir Note that a plain CanvasHelper, although it does support the 47*cdf0e10cSrcweir XBitmap interface, has no provision for alpha channel on VCL 48*cdf0e10cSrcweir (at least no efficient one. If the alpha VDev one day gets 49*cdf0e10cSrcweir part of SAL, we might change that). 50*cdf0e10cSrcweir */ 51*cdf0e10cSrcweir class CanvasBitmapHelper : public CanvasHelper 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir public: 54*cdf0e10cSrcweir CanvasBitmapHelper(); 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir /** Set a new bitmap on this helper. 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir This method late-initializes the bitmap canvas helper, 59*cdf0e10cSrcweir providing it with the necessary device and output 60*cdf0e10cSrcweir objects. The internally stored bitmap representation is 61*cdf0e10cSrcweir updated from the given bitmap, including any size 62*cdf0e10cSrcweir changes. Note that the CanvasHelper does <em>not</em> take 63*cdf0e10cSrcweir ownership of the SpriteCanvas object, nor does it perform 64*cdf0e10cSrcweir any reference counting. Thus, to prevent reference counted 65*cdf0e10cSrcweir objects from deletion, the user of this class is 66*cdf0e10cSrcweir responsible for holding ref-counted references to those 67*cdf0e10cSrcweir objects! 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir @param rBitmap 70*cdf0e10cSrcweir Content of this bitmap is used as our new content (our 71*cdf0e10cSrcweir internal size is adapted to the size of the bitmap given) 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir @param rDevice 74*cdf0e10cSrcweir Reference device for this canvas bitmap 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir @param rOutDevProvider 77*cdf0e10cSrcweir Reference output device. Used to create matching bitmap. 78*cdf0e10cSrcweir */ 79*cdf0e10cSrcweir void init( const BitmapEx& rBitmap, 80*cdf0e10cSrcweir ::com::sun::star::rendering::XGraphicDevice& rDevice, 81*cdf0e10cSrcweir const OutDevProviderSharedPtr& rOutDevProvider ); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir // Overridden CanvasHelper functionality 85*cdf0e10cSrcweir // ===================================== 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir void disposing(); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void clear(); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir ::com::sun::star::geometry::IntegerSize2D getSize(); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > queryBitmapCanvas(); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > 96*cdf0e10cSrcweir getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize, 97*cdf0e10cSrcweir sal_Bool beFast ); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > 100*cdf0e10cSrcweir getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 101*cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data, 104*cdf0e10cSrcweir const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 105*cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color, 108*cdf0e10cSrcweir const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 109*cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerPoint2D& pos ); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > 112*cdf0e10cSrcweir getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 113*cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerPoint2D& pos ); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout(); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir /// @internal 118*cdf0e10cSrcweir BitmapEx getBitmap() const; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir private: 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir void setBitmap( const BitmapEx& rBitmap ); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir BitmapBackBufferSharedPtr mpBackBuffer; 125*cdf0e10cSrcweir OutDevProviderSharedPtr mpOutDevReference; 126*cdf0e10cSrcweir }; 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir #endif /* _VCLCANVAS_CANVASBITMAPHELPER_HXX_ */ 130