1*91c99ff4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*91c99ff4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*91c99ff4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*91c99ff4SAndrew Rist * distributed with this work for additional information 6*91c99ff4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*91c99ff4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*91c99ff4SAndrew Rist * "License"); you may not use this file except in compliance 9*91c99ff4SAndrew Rist * with the License. You may obtain a copy of the License at 10*91c99ff4SAndrew Rist * 11*91c99ff4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*91c99ff4SAndrew Rist * 13*91c99ff4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*91c99ff4SAndrew Rist * software distributed under the License is distributed on an 15*91c99ff4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*91c99ff4SAndrew Rist * KIND, either express or implied. See the License for the 17*91c99ff4SAndrew Rist * specific language governing permissions and limitations 18*91c99ff4SAndrew Rist * under the License. 19*91c99ff4SAndrew Rist * 20*91c99ff4SAndrew Rist *************************************************************/ 21*91c99ff4SAndrew Rist 22*91c99ff4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _VCLCANVAS_CANVASBITMAPHELPER_HXX_ 25cdf0e10cSrcweir #define _VCLCANVAS_CANVASBITMAPHELPER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <canvashelper.hxx> 28cdf0e10cSrcweir #include <canvas/vclwrapper.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include "bitmapbackbuffer.hxx" 33cdf0e10cSrcweir #include "spritecanvas.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace vclcanvas 37cdf0e10cSrcweir { 38cdf0e10cSrcweir /** Helper class for basic canvasbitmap functionality. Extends 39cdf0e10cSrcweir CanvasHelper with some CanvasBitmap specialities, such as alpha 40cdf0e10cSrcweir support. 41cdf0e10cSrcweir 42cdf0e10cSrcweir Note that a plain CanvasHelper, although it does support the 43cdf0e10cSrcweir XBitmap interface, has no provision for alpha channel on VCL 44cdf0e10cSrcweir (at least no efficient one. If the alpha VDev one day gets 45cdf0e10cSrcweir part of SAL, we might change that). 46cdf0e10cSrcweir */ 47cdf0e10cSrcweir class CanvasBitmapHelper : public CanvasHelper 48cdf0e10cSrcweir { 49cdf0e10cSrcweir public: 50cdf0e10cSrcweir CanvasBitmapHelper(); 51cdf0e10cSrcweir 52cdf0e10cSrcweir /** Set a new bitmap on this helper. 53cdf0e10cSrcweir 54cdf0e10cSrcweir This method late-initializes the bitmap canvas helper, 55cdf0e10cSrcweir providing it with the necessary device and output 56cdf0e10cSrcweir objects. The internally stored bitmap representation is 57cdf0e10cSrcweir updated from the given bitmap, including any size 58cdf0e10cSrcweir changes. Note that the CanvasHelper does <em>not</em> take 59cdf0e10cSrcweir ownership of the SpriteCanvas object, nor does it perform 60cdf0e10cSrcweir any reference counting. Thus, to prevent reference counted 61cdf0e10cSrcweir objects from deletion, the user of this class is 62cdf0e10cSrcweir responsible for holding ref-counted references to those 63cdf0e10cSrcweir objects! 64cdf0e10cSrcweir 65cdf0e10cSrcweir @param rBitmap 66cdf0e10cSrcweir Content of this bitmap is used as our new content (our 67cdf0e10cSrcweir internal size is adapted to the size of the bitmap given) 68cdf0e10cSrcweir 69cdf0e10cSrcweir @param rDevice 70cdf0e10cSrcweir Reference device for this canvas bitmap 71cdf0e10cSrcweir 72cdf0e10cSrcweir @param rOutDevProvider 73cdf0e10cSrcweir Reference output device. Used to create matching bitmap. 74cdf0e10cSrcweir */ 75cdf0e10cSrcweir void init( const BitmapEx& rBitmap, 76cdf0e10cSrcweir ::com::sun::star::rendering::XGraphicDevice& rDevice, 77cdf0e10cSrcweir const OutDevProviderSharedPtr& rOutDevProvider ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir 80cdf0e10cSrcweir // Overridden CanvasHelper functionality 81cdf0e10cSrcweir // ===================================== 82cdf0e10cSrcweir 83cdf0e10cSrcweir void disposing(); 84cdf0e10cSrcweir 85cdf0e10cSrcweir void clear(); 86cdf0e10cSrcweir 87cdf0e10cSrcweir ::com::sun::star::geometry::IntegerSize2D getSize(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > queryBitmapCanvas(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > 92cdf0e10cSrcweir getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize, 93cdf0e10cSrcweir sal_Bool beFast ); 94cdf0e10cSrcweir 95cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > 96cdf0e10cSrcweir getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 97cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data, 100cdf0e10cSrcweir const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 101cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color, 104cdf0e10cSrcweir const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 105cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerPoint2D& pos ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > 108cdf0e10cSrcweir getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 109cdf0e10cSrcweir const ::com::sun::star::geometry::IntegerPoint2D& pos ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout(); 112cdf0e10cSrcweir 113cdf0e10cSrcweir /// @internal 114cdf0e10cSrcweir BitmapEx getBitmap() const; 115cdf0e10cSrcweir 116cdf0e10cSrcweir private: 117cdf0e10cSrcweir 118cdf0e10cSrcweir void setBitmap( const BitmapEx& rBitmap ); 119cdf0e10cSrcweir 120cdf0e10cSrcweir BitmapBackBufferSharedPtr mpBackBuffer; 121cdf0e10cSrcweir OutDevProviderSharedPtr mpOutDevReference; 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir #endif /* _VCLCANVAS_CANVASBITMAPHELPER_HXX_ */ 126