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 INCLUDED_BASEBMP_BITMAPDEVICE_HXX
25 #define INCLUDED_BASEBMP_BITMAPDEVICE_HXX
26 
27 #include <sal/types.h>
28 #include <basebmp/drawmodes.hxx>
29 
30 #include <boost/scoped_ptr.hpp>
31 #include <boost/shared_ptr.hpp>
32 #include <boost/shared_array.hpp>
33 #include <boost/enable_shared_from_this.hpp>
34 #include <boost/noncopyable.hpp>
35 #include <vector>
36 
37 #if defined BASEBMP_DLLIMPLEMENTATION
38 #define BASEBMP_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
39 #else
40 #define BASEBMP_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
41 #endif
42 #define BASEBMP_DLLPRIVATE SAL_DLLPRIVATE
43 
44 namespace basegfx
45 {
46     class B2IPoint;
47     class B2DPoint;
48     class B2IVector;
49     class B2IRange;
50     class B2DPolygon;
51     class B2DPolyPolygon;
52 }
53 
54 namespace basebmp
55 {
56 
57 // Temporary. Use like the tools color object
58 class Color;
59 typedef boost::shared_ptr< class BitmapDevice >         BitmapDeviceSharedPtr;
60 typedef boost::shared_array< sal_uInt8 >                RawMemorySharedArray;
61 typedef boost::shared_ptr< const std::vector<Color> >   PaletteMemorySharedVector;
62 
63 struct ImplBitmapDevice;
64 
65 /** Definition of BitmapDevice interface
66 
67     Use the createBitmapDevice() factory method to create instances.
68 
69     Implementation note: the clip mask and bitmap parameter instances
70     of BitmapDevice that are passed to individual BitmapDevice
71     instances work best with 1 bit grey masks for the clip and a
72     format matching that of the target BitmapDevice for the other
73     parameters. The alpha mask passed to the drawMaskedColor() methods
74     works best when given as an eight bit grey bitmap. Everything else
75     is accepted, but potentially slow.
76  */
77 class BASEBMP_DLLPUBLIC BitmapDevice : public boost::enable_shared_from_this<BitmapDevice>,
78                      private boost::noncopyable
79 {
80 public:
81     /** Query size of device in pixel
82      */
83     basegfx::B2IVector getSize() const;
84 
85     /** Query whether buffer starts with 0th scanline
86 
87         @return true, if the buffer memory starts with the 0th
88         scanline, and false if it starts with the last one. The latter
89         is e.g. the typical scan line ordering for the Windows BMP
90         format.
91      */
92     bool isTopDown() const;
93 
94     /** Query type of scanline memory format
95      */
96     sal_Int32 getScanlineFormat() const;
97 
98     /** Query byte offset to get from scanline n to scanline n+1
99 
100         @return the scanline stride in bytes. In the case of
101         isTopDown()==false, this offset will be negative.
102      */
103     sal_Int32 getScanlineStride() const;
104 
105     /** Get pointer to frame buffer
106 
107         @return a shared ptr to the bitmap buffer memory. As this is a
108         shared ptr, you can freely store and use the pointer, even
109         after this object has been deleted.
110      */
111     RawMemorySharedArray getBuffer() const;
112 
113     /** Get pointer to palette
114 
115         The returned pointer is const on purpose, since the
116         BitmapDevice might internally cache lookup information. Don't
117         modify the returned data, unless you want to enter the realm
118         of completely undefined behaviour.
119 
120         @return shared pointer to vector of Color entries.
121      */
122     PaletteMemorySharedVector getPalette() const;
123 
124     /** Query number of palette entries.
125 
126         This is just a frontend for getPalette->size()
127      */
128     sal_Int32 getPaletteEntryCount() const;
129 
130     /** Clear whole device with given color
131 
132         This method works like a fill with the given color value,
133         resulting in a bitmap uniformly colored in fillColor.
134      */
135     void clear( Color fillColor );
136 
137     /** Set given pixel to specified color
138 
139         @param rPt
140         Pixel to set
141 
142         @param pixelColor
143         Color value to set the pixel to
144 
145         @param drawMode
146         Draw mode to use when changing the pixel value
147      */
148     void setPixel( const basegfx::B2IPoint& rPt,
149                    Color                    pixelColor,
150                    DrawMode                 drawMode );
151 
152     /** Set given pixel to specified color
153 
154         @param rPt
155         Pixel to set
156 
157         @param pixelColor
158         Color value to set the pixel to
159 
160         @param drawMode
161         Draw mode to use when changing the pixel value
162 
163         @param rClip
164         Clip mask to use. If the clip mask is 1 at the given pixel
165         position, no change will take place.
166      */
167     void setPixel( const basegfx::B2IPoint&     rPt,
168                    Color                        pixelColor,
169                    DrawMode                     drawMode,
170                    const BitmapDeviceSharedPtr& rClip );
171 
172     /** Get color value at given pixel
173      */
174     Color getPixel( const basegfx::B2IPoint& rPt );
175 
176     /** Get underlying pixel data value at given position
177 
178         This method returns the raw pixel data. In the case of
179         paletted bitmaps, this is the palette index, not the final
180         color value.
181      */
182     sal_uInt32 getPixelData( const basegfx::B2IPoint& rPt );
183 
184     /** Draw a line
185 
186         @param rPt1
187         Start point of the line
188 
189         @param rPt2
190         End point of the line. If the analytical line from rP1 to rPt2
191         (with the actual pixel positions assumed to be the center of
192         the pixel) is exactly in the middle between two pixel, this
193         method always selects the pixel closer to rPt1.
194 
195         @param lineColor
196         Color value to draw the line with
197 
198         @param drawMode
199         Draw mode to use when changing the pixel value
200      */
201     void drawLine( const basegfx::B2IPoint& rPt1,
202                    const basegfx::B2IPoint& rPt2,
203                    Color                    lineColor,
204                    DrawMode                 drawMode );
205 
206     /** Draw a line
207 
208         @param rPt1
209         Start point of the line
210 
211         @param rPt2
212         End point of the line. If the analytical line from rP1 to rPt2
213         (with the actual pixel positions assumed to be the center of
214         the pixel) is exactly in the middle between two pixel, this
215         method always selects the pixel closer to rPt1.
216 
217         @param lineColor
218         Color value to draw the line with
219 
220         @param drawMode
221         Draw mode to use when changing the pixel value
222 
223         @param rClip
224         Clip mask to use. Pixel where the corresponding clip mask
225         pixel is 1 will not be modified.
226      */
227     void drawLine( const basegfx::B2IPoint&     rPt1,
228                    const basegfx::B2IPoint&     rPt2,
229                    Color                        lineColor,
230                    DrawMode                     drawMode,
231                    const BitmapDeviceSharedPtr& rClip );
232 
233     /** Draw a polygon
234 
235         @param rPoly
236         Polygon to draw. Depending on the value returned by rPoly's
237         isClosed() method, the resulting line polygon will be drawn
238         closed or not.
239 
240         @param lineColor
241         Color value to draw the polygon with
242 
243         @param drawMode
244         Draw mode to use when changing pixel values
245      */
246     void drawPolygon( const basegfx::B2DPolygon& rPoly,
247                       Color                      lineColor,
248                       DrawMode                   drawMode );
249 
250     /** Draw a polygon
251 
252         @param rPoly
253         Polygon to draw. Depending on the value returned by rPoly's
254         isClosed() method, the resulting line polygon will be drawn
255         closed or not.
256 
257         @param lineColor
258         Color value to draw the polygon with
259 
260         @param drawMode
261         Draw mode to use when changing pixel values
262 
263         @param rClip
264         Clip mask to use. Pixel where the corresponding clip mask
265         pixel is 1 will not be modified.
266      */
267     void drawPolygon( const basegfx::B2DPolygon&   rPoly,
268                       Color                        lineColor,
269                       DrawMode                     drawMode,
270                       const BitmapDeviceSharedPtr& rClip );
271 
272     /** Fill a poly-polygon
273 
274         @param rPoly
275         Poly-polygon to fill. Regardless of the value returned by
276         rPoly's isClosed() method, the resulting filled poly-polygon
277         is always considered closed. As usual, when filling a shape,
278         the rightmost and bottommost pixel are not filled, compared to
279         the drawPolygon() method. For example, the rectangle
280         (0,0),(1,1) will have four pixel set, when drawn via
281         drawPolygon(), and only one pixel, when filled via
282         fillPolyPolygon().
283 
284         @param fillColor
285         Color value to fill the poly-polygon with
286 
287         @param drawMode
288         Draw mode to use when changing pixel values
289      */
290     void fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
291                           Color                          fillColor,
292                           DrawMode                       drawMode );
293 
294     /** Fill a poly-polygon
295 
296         @param rPoly
297         Poly-polygon to fill. Regardless of the value returned by
298         rPoly's isClosed() method, the resulting filled poly-polygon
299         is always considered closed. As usual, when filling a shape,
300         the rightmost and bottommost pixel are not filled, compared to
301         the drawPolygon() method. For example, the rectangle
302         (0,0),(1,1) will have four pixel set, when drawn via
303         drawPolygon(), and only one pixel, when filled via
304         fillPolyPolygon().
305 
306         @param fillColor
307         Color value to fill the poly-polygon with
308 
309         @param drawMode
310         Draw mode to use when changing pixel values
311 
312         @param rClip
313         Clip mask to use. Pixel where the corresponding clip mask
314         pixel is 1 will not be modified.
315      */
316     void fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
317                           Color                          fillColor,
318                           DrawMode                       drawMode,
319                           const BitmapDeviceSharedPtr&   rClip );
320 
321     /** Draw another bitmap into this device
322 
323         @param rSrcBitmap
324         Bitmap to render into this one. It is permitted that source
325         and destination bitmap are the same.
326 
327         @param rSrcRect
328         Rectangle within the source bitmap to take the pixel from.
329 
330         @param rDstRect
331         Rectangle in the destination bitmap to put the pixel
332         into. Source and destination rectangle are permitted to have
333         differing sizes; this method will scale the source pixel
334         accordingly. Please note that both source and destination
335         rectangle are interpreted excluding the rightmost pixel column
336         and the bottommost pixel row, this is much like polygon
337         filling. As a result, filling a given rectangle with
338         fillPolyPolygon(), and using the same rectangle as the
339         destination rectangle of this method, will affect exactly the
340         same set of pixel.
341 
342         @param drawMode
343         Draw mode to use when changing pixel values
344      */
345     void drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
346                      const basegfx::B2IRange&     rSrcRect,
347                      const basegfx::B2IRange&     rDstRect,
348                      DrawMode                     drawMode );
349 
350     /** Draw another bitmap into this device
351 
352         @param rSrcBitmap
353         Bitmap to render into this one. It is permitted that source
354         and destination bitmap are the same.
355 
356         @param rSrcRect
357         Rectangle within the source bitmap to take the pixel from.
358 
359         @param rDstRect
360         Rectangle in the destination bitmap to put the pixel
361         into. Source and destination rectangle are permitted to have
362         differing sizes; this method will scale the source pixel
363         accordingly. Please note that both source and destination
364         rectangle are interpreted excluding the rightmost pixel column
365         and the bottommost pixel row, this is much like polygon
366         filling. As a result, filling a given rectangle with
367         fillPolyPolygon(), and using the same rectangle as the
368         destination rectangle of this method, will affect exactly the
369         same set of pixel.
370 
371         @param drawMode
372         Draw mode to use when changing pixel values
373 
374         @param rClip
375         Clip mask to use. Pixel where the corresponding clip mask
376         pixel is 1 will not be modified.
377      */
378     void drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
379                      const basegfx::B2IRange&     rSrcRect,
380                      const basegfx::B2IRange&     rDstRect,
381                      DrawMode                     drawMode,
382                      const BitmapDeviceSharedPtr& rClip );
383 
384     /** Draw a color with an alpha-modulation bitmap into this device
385 
386         This method takes a fixed color value, and an alpha mask. For
387         each pixel in the alpha mask, the given color value is blended
388         with the corresponding alpha value against the content of this
389         object.
390 
391         @param aSrcColor
392         Color value to use for blending
393 
394         @param rAlphaMask
395         Alpha mask to use for blending. It is permitted that alpha
396         mask and this bitmap are the same object.
397 
398         @param rSrcRect
399         Rectangle within the alpha mask to take the pixel from.
400         Please note that the destination rectangle is interpreted
401         excluding the rightmost pixel column and the bottommost pixel
402         row, this is much like polygon filling. As a result, filling a
403         given rectangle with fillPolyPolygon(), and using the same
404         rectangle as the source rectangle of this method, will affect
405         exactly the same set of pixel.
406 
407         @param rDstPoint
408         Destination point, where to start placing the pixel from the
409         source rectangle
410      */
411     void drawMaskedColor( Color                        aSrcColor,
412                           const BitmapDeviceSharedPtr& rAlphaMask,
413                           const basegfx::B2IRange&     rSrcRect,
414                           const basegfx::B2IPoint&     rDstPoint );
415 
416     /** Draw a color with an alpha-modulation bitmap into this device
417 
418         This method takes a fixed color value, and an alpha mask. For
419         each pixel in the alpha mask, the given color value is blended
420         with the corresponding alpha value against the content of this
421         object.
422 
423         @param aSrcColor
424         Color value to use for blending
425 
426         @param rAlphaMask
427         Alpha mask to use for blending. It is permitted that alpha
428         mask and this bitmap are the same object.
429 
430         @param rSrcRect
431         Rectangle within the alpha mask to take the pixel from.
432         Please note that the destination rectangle is interpreted
433         excluding the rightmost pixel column and the bottommost pixel
434         row, this is much like polygon filling. As a result, filling a
435         given rectangle with fillPolyPolygon(), and using the same
436         rectangle as the source rectangle of this method, will affect
437         exactly the same set of pixel.
438 
439         @param rDstPoint
440         Destination point, where to start placing the pixel from the
441         source rectangle
442 
443         @param rClip
444         Clip mask to use. Pixel where the corresponding clip mask
445         pixel is 1 will not be modified.
446      */
447     void drawMaskedColor( Color                        aSrcColor,
448                           const BitmapDeviceSharedPtr& rAlphaMask,
449                           const basegfx::B2IRange&     rSrcRect,
450                           const basegfx::B2IPoint&     rDstPoint,
451                           const BitmapDeviceSharedPtr& rClip );
452 
453     /** Draw another bitmap through a mask into this device
454 
455         This method renders a source bitmap into this device, much
456         like the drawBitmap() method. The only difference is the
457         additional mask parameter, which operates much like an
458         additional clip mask: pixel with value zero in this mask
459         result in destination pixel not being modified.
460 
461         @param rSrcBitmap
462         Bitmap to render into this one. It is permitted that source
463         and destination bitmap are the same.
464 
465         @param rMask
466         Bitmap to use as a mask. Pixel with value != zero in this mask
467         will result in destination pixel not being affected by the
468         blit operation.
469 
470         @param rSrcRect
471         Rectangle within the source bitmap to take the pixel from.
472 
473         @param rDstRect
474         Rectangle in the destination bitmap to put the pixel
475         into. Source and destination rectangle are permitted to have
476         differing sizes; this method will scale the source pixel
477         accordingly. Please note that both source and destination
478         rectangle are interpreted excluding the rightmost pixel column
479         and the bottommost pixel row, this is much like polygon
480         filling. As a result, filling a given rectangle with
481         fillPolyPolygon(), and using the same rectangle as the
482         destination rectangle of this method, will affect exactly the
483         same set of pixel.
484 
485         @param drawMode
486         Draw mode to use when changing pixel values
487      */
488     void drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
489                            const BitmapDeviceSharedPtr& rMask,
490                            const basegfx::B2IRange&     rSrcRect,
491                            const basegfx::B2IRange&     rDstRect,
492                            DrawMode                     drawMode );
493 
494     /** Draw another bitmap through a mask into this device
495 
496         This method renders a source bitmap into this device, much
497         like the drawBitmap() method. The only difference is the
498         additional mask parameter, which operates much like an
499         additional clip mask: pixel with value != zero in this mask
500         result in destination pixel not being modified.
501 
502         @param rSrcBitmap
503         Bitmap to render into this one. It is permitted that source
504         and destination bitmap are the same.
505 
506         @param rMask
507         Bitmap to use as a mask. Pixel with value != zero in this mask
508         will result in destination pixel not being affected by the
509         blit operation.
510 
511         @param rSrcRect
512         Rectangle within the source bitmap to take the pixel from.
513 
514         @param rDstRect
515         Rectangle in the destination bitmap to put the pixel
516         into. Source and destination rectangle are permitted to have
517         differing sizes; this method will scale the source pixel
518         accordingly. Please note that both source and destination
519         rectangle are interpreted excluding the rightmost pixel column
520         and the bottommost pixel row, this is much like polygon
521         filling. As a result, filling a given rectangle with
522         fillPolyPolygon(), and using the same rectangle as the
523         destination rectangle of this method, will affect exactly the
524         same set of pixel.
525 
526         @param drawMode
527         Draw mode to use when changing pixel values
528 
529         @param rClip
530         Clip mask to use. Pixel where the corresponding clip mask
531         pixel is 1 will not be modified.
532      */
533     void drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
534                            const BitmapDeviceSharedPtr& rMask,
535                            const basegfx::B2IRange&     rSrcRect,
536                            const basegfx::B2IRange&     rDstRect,
537                            DrawMode                     drawMode,
538                            const BitmapDeviceSharedPtr& rClip );
539 
540 protected:
541     BitmapDevice( const basegfx::B2IRange&         rBounds,
542                   sal_Int32                        nScanlineFormat,
543                   sal_Int32                        nScanlineStride,
544                   sal_uInt8*                       pFirstScanline,
545                   const RawMemorySharedArray&      rMem,
546                   const PaletteMemorySharedVector& rPalette );
547 
548     virtual ~BitmapDevice();
549 
550 private:
551     virtual bool isCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) const = 0;
552     virtual bool isCompatibleClipMask( const BitmapDeviceSharedPtr& bmp ) const = 0;
553     virtual bool isCompatibleAlphaMask( const BitmapDeviceSharedPtr& bmp ) const = 0;
554 
555     virtual void clear_i( Color                     fillColor,
556                           const basegfx::B2IRange&  rBounds ) = 0;
557 
558     virtual void setPixel_i( const basegfx::B2IPoint& rPt,
559                              Color                    lineColor,
560                              DrawMode                 drawMode ) = 0;
561     virtual void setPixel_i( const basegfx::B2IPoint&     rPt,
562                              Color                        lineColor,
563                              DrawMode                     drawMode,
564                              const BitmapDeviceSharedPtr& rClip ) = 0;
565 
566     virtual Color getPixel_i( const basegfx::B2IPoint& rPt ) = 0;
567 
568     virtual sal_uInt32 getPixelData_i( const basegfx::B2IPoint& rPt ) = 0;
569 
570     virtual void drawLine_i( const basegfx::B2IPoint& rPt1,
571                              const basegfx::B2IPoint& rPt2,
572                              const basegfx::B2IRange& rBounds,
573                              Color                    lineColor,
574                              DrawMode                 drawMode ) = 0;
575     virtual void drawLine_i( const basegfx::B2IPoint&     rPt1,
576                              const basegfx::B2IPoint&     rPt2,
577                              const basegfx::B2IRange&     rBounds,
578                              Color                        lineColor,
579                              DrawMode                     drawMode,
580                              const BitmapDeviceSharedPtr& rClip ) = 0;
581 
582     virtual void drawPolygon_i( const basegfx::B2DPolygon& rPoly,
583                                 const basegfx::B2IRange&   rBounds,
584                                 Color                      lineColor,
585                                 DrawMode                   drawMode ) = 0;
586     virtual void drawPolygon_i( const basegfx::B2DPolygon&   rPoly,
587                                 const basegfx::B2IRange&     rBounds,
588                                 Color                        lineColor,
589                                 DrawMode                     drawMode,
590                                 const BitmapDeviceSharedPtr& rClip ) = 0;
591 
592     virtual void fillPolyPolygon_i( const basegfx::B2DPolyPolygon& rPoly,
593                                     Color                          fillColor,
594                                     DrawMode                       drawMode,
595                                     const basegfx::B2IRange&       rBounds ) = 0;
596     virtual void fillPolyPolygon_i( const basegfx::B2DPolyPolygon& rPoly,
597                                     Color                          fillColor,
598                                     DrawMode                       drawMode,
599                                     const basegfx::B2IRange&       rBounds,
600                                     const BitmapDeviceSharedPtr&   rClip ) = 0;
601 
602     // must work with *this == rSrcBitmap!
603     virtual void drawBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
604                                const basegfx::B2IRange&     rSrcRect,
605                                const basegfx::B2IRange&     rDstRect,
606                                DrawMode                     drawMode ) = 0;
607     virtual void drawBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
608                                const basegfx::B2IRange&     rSrcRect,
609                                const basegfx::B2IRange&     rDstRect,
610                                DrawMode                     drawMode,
611                                const BitmapDeviceSharedPtr& rClip ) = 0;
612 
613     // must work with *this == rSrcBitmap!
614     virtual void drawMaskedColor_i( Color                        rSrcColor,
615                                     const BitmapDeviceSharedPtr& rAlphaMask,
616                                     const basegfx::B2IRange&     rSrcRect,
617                                     const basegfx::B2IPoint&     rDstPoint ) = 0;
618     virtual void drawMaskedColor_i( Color                        rSrcColor,
619                                     const BitmapDeviceSharedPtr& rAlphaMask,
620                                     const basegfx::B2IRange&     rSrcRect,
621                                     const basegfx::B2IPoint&     rDstPoint,
622                                     const BitmapDeviceSharedPtr& rClip ) = 0;
623 
624     // must work with *this == rSrcBitmap!
625     virtual void drawMaskedBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
626                                      const BitmapDeviceSharedPtr& rMask,
627                                      const basegfx::B2IRange&     rSrcRect,
628                                      const basegfx::B2IRange&     rDstRect,
629                                      DrawMode                     drawMode ) = 0;
630     virtual void drawMaskedBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
631                                      const BitmapDeviceSharedPtr& rMask,
632                                      const basegfx::B2IRange&     rSrcRect,
633                                      const basegfx::B2IRange&     rDstRect,
634                                      DrawMode                     drawMode,
635                                      const BitmapDeviceSharedPtr& rClip ) = 0;
636 
637     BitmapDeviceSharedPtr getGenericRenderer() const;
638 
639     boost::scoped_ptr< ImplBitmapDevice > mpImpl;
640 };
641 
642 /** Factory method to create a BitmapDevice for given scanline format
643  */
644 BASEBMP_DLLPUBLIC BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
645                                           bool                      bTopDown,
646                                           sal_Int32                 nScanlineFormat );
647 
648 /** Factory method to create a BitmapDevice for given scanline format
649     with the given palette
650 
651     Note: the provided palette must have sufficient size, to satisfy
652     lookups for the whole range of pixel values from the specified
653     format.
654  */
655 BASEBMP_DLLPUBLIC BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector&        rSize,
656                                           bool                             bTopDown,
657                                           sal_Int32                        nScanlineFormat,
658                                           const PaletteMemorySharedVector& rPalette );
659 
660 /** Factory method to create a BitmapDevice for given scanline format
661     from the given piece of raw memory and palette
662 
663     Note: the provided memory must have sufficient size, to store the
664     image of the specified area and format.
665  */
666 BASEBMP_DLLPUBLIC BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector&        rSize,
667                                           bool                             bTopDown,
668                                           sal_Int32                        nScanlineFormat,
669                                           const RawMemorySharedArray&      rMem,
670                                           const PaletteMemorySharedVector& rPalette );
671 
672 
673 /** Factory method to retrieve a subsetted BitmapDevice to the same
674     memory.
675 
676     This method creates a second bitmap device instance, which renders
677     to the same memory as the original, but to a limited, rectangular
678     area. Useful to implement rectangular clips (usually faster than
679     setting up a 1bpp clip mask).
680  */
681 BASEBMP_DLLPUBLIC BitmapDeviceSharedPtr subsetBitmapDevice( const BitmapDeviceSharedPtr&     rProto,
682                                           const basegfx::B2IRange&         rSubset );
683 
684 /** Factory method to clone a BitmapDevice from a given prototype.
685 
686     All attributes (like scanline format and top-down state) are
687     copied, only the size can be varied. Note that the prototype's
688     bitmap content is <em>not</em> copied, only a palette (if any).
689  */
690 BASEBMP_DLLPUBLIC BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector&        rSize,
691                                          const BitmapDeviceSharedPtr&     rProto );
692 
693 }
694 
695 #endif /* INCLUDED_BASEBMP_BITMAPDEVICE_HXX */
696