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