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