summaryrefslogtreecommitdiff
path: root/basebmp/inc/basebmp/bitmapdevice.hxx
blob: b1c513444fe6d896eb0400cef0f25dfae2a4cebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef INCLUDED_BASEBMP_BITMAPDEVICE_HXX
#define INCLUDED_BASEBMP_BITMAPDEVICE_HXX

#include <sal/types.h>
#include <basebmp/drawmodes.hxx>

#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/noncopyable.hpp>
#include <vector>

namespace basegfx
{
    class B2IPoint;
    class B2DPoint;
    class B2IVector;
    class B2IRange;
    class B2DPolygon;
    class B2DPolyPolygon;
}

namespace basebmp
{

// Temporary. Use like the tools color object
class Color;
typedef boost::shared_ptr< class BitmapDevice >         BitmapDeviceSharedPtr;
typedef boost::shared_array< sal_uInt8 >                RawMemorySharedArray;
typedef boost::shared_ptr< const std::vector<Color> >   PaletteMemorySharedVector;

struct ImplBitmapDevice;

/** Definition of BitmapDevice interface

    Use the createBitmapDevice() factory method to create instances.

    Implementation note: the clip mask and bitmap parameter instances
    of BitmapDevice that are passed to individual BitmapDevice
    instances work best with 1 bit grey masks for the clip and a
    format matching that of the target BitmapDevice for the other
    parameters. The alpha mask passed to the drawMaskedColor() methods
    works best when given as an eight bit grey bitmap. Everything else
    is accepted, but potentially slow.
 */
class BitmapDevice : public boost::enable_shared_from_this<BitmapDevice>,
                     private boost::noncopyable
{
public:
    /** Query size of device in pixel
     */
    basegfx::B2IVector getSize() const;

    /** Query whether buffer starts with 0th scanline

        @return true, if the buffer memory starts with the 0th
        scanline, and false if it starts with the last one. The latter
        is e.g. the typical scan line ordering for the Windows BMP
        format.
     */
    bool isTopDown() const;

    /** Query type of scanline memory format
     */
    sal_Int32 getScanlineFormat() const;

    /** Query byte offset to get from scanline n to scanline n+1

        @return the scanline stride in bytes. In the case of
        isTopDown()==false, this offset will be negative.
     */
    sal_Int32 getScanlineStride() const;

    /** Get pointer to frame buffer

        @return a shared ptr to the bitmap buffer memory. As this is a
        shared ptr, you can freely store and use the pointer, even
        after this object has been deleted.
     */
    RawMemorySharedArray getBuffer() const;

    /** Get pointer to palette

        The returned pointer is const on purpose, since the
        BitmapDevice might internally cache lookup information. Don't
        modify the returned data, unless you want to enter the realm
        of completely undefined behaviour.

        @return shared pointer to vector of Color entries.
     */
    PaletteMemorySharedVector getPalette() const;

    /** Query number of palette entries.

        This is just a frontend for getPalette->size()
     */
    sal_Int32 getPaletteEntryCount() const;

    /** Clear whole device with given color

        This method works like a fill with the given color value,
        resulting in a bitmap uniformly colored in fillColor.
     */
    void clear( Color fillColor );

    /** Set given pixel to specified color

        @param rPt
        Pixel to set

        @param pixelColor
        Color value to set the pixel to

        @param drawMode
        Draw mode to use when changing the pixel value
     */
    void setPixel( const basegfx::B2IPoint& rPt,
                   Color                    pixelColor,
                   DrawMode                 drawMode );

    /** Set given pixel to specified color

        @param rPt
        Pixel to set

        @param pixelColor
        Color value to set the pixel to

        @param drawMode
        Draw mode to use when changing the pixel value

        @param rClip
        Clip mask to use. If the clip mask is 1 at the given pixel
        position, no change will take place.
     */
    void setPixel( const basegfx::B2IPoint&     rPt,
                   Color                        pixelColor,
                   DrawMode                     drawMode,
                   const BitmapDeviceSharedPtr& rClip );

    /** Get color value at given pixel
     */
    Color getPixel( const basegfx::B2IPoint& rPt );

    /** Get underlying pixel data value at given position

        This method returns the raw pixel data. In the case of
        paletted bitmaps, this is the palette index, not the final
        color value.
     */
    sal_uInt32 getPixelData( const basegfx::B2IPoint& rPt );

    /** Draw a line

        @param rPt1
        Start point of the line

        @param rPt2
        End point of the line. If the analytical line from rP1 to rPt2
        (with the actual pixel positions assumed to be the center of
        the pixel) is exactly in the middle between two pixel, this
        method always selects the pixel closer to rPt1.

        @param lineColor
        Color value to draw the line with

        @param drawMode
        Draw mode to use when changing the pixel value
     */
    void drawLine( const basegfx::B2IPoint& rPt1,
                   const basegfx::B2IPoint& rPt2,
                   Color                    lineColor,
                   DrawMode                 drawMode );

    /** Draw a line

        @param rPt1
        Start point of the line

        @param rPt2
        End point of the line. If the analytical line from rP1 to rPt2
        (with the actual pixel positions assumed to be the center of
        the pixel) is exactly in the middle between two pixel, this
        method always selects the pixel closer to rPt1.

        @param lineColor
        Color value to draw the line with

        @param drawMode
        Draw mode to use when changing the pixel value

        @param rClip
        Clip mask to use. Pixel where the corresponding clip mask
        pixel is 1 will not be modified.
     */
    void drawLine( const basegfx::B2IPoint&     rPt1,
                   const basegfx::B2IPoint&     rPt2,
                   Color                        lineColor,
                   DrawMode                     drawMode,
                   const BitmapDeviceSharedPtr& rClip );

    /** Draw a polygon

        @param rPoly
        Polygon to draw. Depending on the value returned by rPoly's
        isClosed() method, the resulting line polygon will be drawn
        closed or not.

        @param lineColor
        Color value to draw the polygon with

        @param drawMode
        Draw mode to use when changing pixel values
     */
    void drawPolygon( const basegfx::B2DPolygon& rPoly,
                      Color                      lineColor,
                      DrawMode                   drawMode );

    /** Draw a polygon

        @param rPoly
        Polygon to draw. Depending on the value returned by rPoly's
        isClosed() method, the resulting line polygon will be drawn
        closed or not.

        @param lineColor
        Color value to draw the polygon with

        @param drawMode
        Draw mode to use when changing pixel values

        @param rClip
        Clip mask to use. Pixel where the corresponding clip mask
        pixel is 1 will not be modified.
     */
    void drawPolygon( const basegfx::B2DPolygon&   rPoly,
                      Color                        lineColor,
                      DrawMode                     drawMode,
                      const BitmapDeviceSharedPtr& rClip );

    /** Fill a poly-polygon

        @param rPoly
        Poly-polygon to fill. Regardless of the value returned by
        rPoly's isClosed() method, the resulting filled poly-polygon
        is always considered closed. As usual, when filling a shape,
        the rightmost and bottommost pixel are not filled, compared to
        the drawPolygon() method. For example, the rectangle
        (0,0),(1,1) will have four pixel set, when drawn via
        drawPolygon(), and only one pixel, when filled via
        fillPolyPolygon().

        @param fillColor
        Color value to fill the poly-polygon with

        @param drawMode
        Draw mode to use when changing pixel values
     */
    void fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
                          Color                          fillColor,
                          DrawMode                       drawMode );

    /** Fill a poly-polygon

        @param rPoly
        Poly-polygon to fill. Regardless of the value returned by
        rPoly's isClosed() method, the resulting filled poly-polygon
        is always considered closed. As usual, when filling a shape,
        the rightmost and bottommost pixel are not filled, compared to
        the drawPolygon() method. For example, the rectangle
        (0,0),(1,1) will have four pixel set, when drawn via
        drawPolygon(), and only one pixel, when filled via
        fillPolyPolygon().

        @param fillColor
        Color value to fill the poly-polygon with

        @param drawMode
        Draw mode to use when changing pixel values

        @param rClip
        Clip mask to use. Pixel where the corresponding clip mask
        pixel is 1 will not be modified.
     */
    void fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
                          Color                          fillColor,
                          DrawMode                       drawMode,
                          const BitmapDeviceSharedPtr&   rClip );

    /** Draw another bitmap into this device

        @param rSrcBitmap
        Bitmap to render into this one. It is permitted that source
        and destination bitmap are the same.

        @param rSrcRect
        Rectangle within the source bitmap to take the pixel from.

        @param rDstRect
        Rectangle in the destination bitmap to put the pixel
        into. Source and destination rectangle are permitted to have
        differing sizes; this method will scale the source pixel
        accordingly. Please note that both source and destination
        rectangle are interpreted excluding the rightmost pixel column
        and the bottommost pixel row, this is much like polygon
        filling. As a result, filling a given rectangle with
        fillPolyPolygon(), and using the same rectangle as the
        destination rectangle of this method, will affect exactly the
        same set of pixel.

        @param drawMode
        Draw mode to use when changing pixel values
     */
    void drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
                     const basegfx::B2IRange&     rSrcRect,
                     const basegfx::B2IRange&     rDstRect,
                     DrawMode                     drawMode );

    /** Draw another bitmap into this device

        @param rSrcBitmap
        Bitmap to render into this one. It is permitted that source
        and destination bitmap are the same.

        @param rSrcRect
        Rectangle within the source bitmap to take the pixel from.

        @param rDstRect
        Rectangle in the destination bitmap to put the pixel
        into. Source and destination rectangle are permitted to have
        differing sizes; this method will scale the source pixel
        accordingly. Please note that both source and destination
        rectangle are interpreted excluding the rightmost pixel column
        and the bottommost pixel row, this is much like polygon
        filling. As a result, filling a given rectangle with
        fillPolyPolygon(), and using the same rectangle as the
        destination rectangle of this method, will affect exactly the
        same set of pixel.

        @param drawMode
        Draw mode to use when changing pixel values

        @param rClip
        Clip mask to use. Pixel where the corresponding clip mask
        pixel is 1 will not be modified.
     */
    void drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
                     const basegfx::B2IRange&     rSrcRect,
                     const basegfx::B2IRange&     rDstRect,
                     DrawMode                     drawMode,
                     const BitmapDeviceSharedPtr& rClip );

    /** Draw a color with an alpha-modulation bitmap into this device

        This method takes a fixed color value, and an alpha mask. For
        each pixel in the alpha mask, the given color value is blended
        with the corresponding alpha value against the content of this
        object.

        @param aSrcColor
        Color value to use for blending

        @param rAlphaMask
        Alpha mask to use for blending. It is permitted that alpha
        mask and this bitmap are the same object.

        @param rSrcRect
        Rectangle within the alpha mask to take the pixel from.
        Please note that the destination rectangle is interpreted
        excluding the rightmost pixel column and the bottommost pixel
        row, this is much like polygon filling. As a result, filling a
        given rectangle with fillPolyPolygon(), and using the same
        rectangle as the source rectangle of this method, will affect
        exactly the same set of pixel.

        @param rDstPoint
        Destination point, where to start placing the pixel from the
        source rectangle
     */
    void drawMaskedColor( Color                        aSrcColor,
                          const BitmapDeviceSharedPtr& rAlphaMask,
                          const basegfx::B2IRange&     rSrcRect,
                          const basegfx::B2IPoint&     rDstPoint );

    /** Draw a color with an alpha-modulation bitmap into this device

        This method takes a fixed color value, and an alpha mask. For
        each pixel in the alpha mask, the given color value is blended
        with the corresponding alpha value against the content of this
        object.

        @param aSrcColor
        Color value to use for blending

        @param rAlphaMask
        Alpha mask to use for blending. It is permitted that alpha
        mask and this bitmap are the same object.

        @param rSrcRect
        Rectangle within the alpha mask to take the pixel from.
        Please note that the destination rectangle is interpreted
        excluding the rightmost pixel column and the bottommost pixel
        row, this is much like polygon filling. As a result, filling a
        given rectangle with fillPolyPolygon(), and using the same
        rectangle as the source rectangle of this method, will affect
        exactly the same set of pixel.

        @param rDstPoint
        Destination point, where to start placing the pixel from the
        source rectangle

        @param rClip
        Clip mask to use. Pixel where the corresponding clip mask
        pixel is 1 will not be modified.
     */
    void drawMaskedColor( Color                        aSrcColor,
                          const BitmapDeviceSharedPtr& rAlphaMask,
                          const basegfx::B2IRange&     rSrcRect,
                          const basegfx::B2IPoint&     rDstPoint,
                          const BitmapDeviceSharedPtr& rClip );

    /** Draw another bitmap through a mask into this device

        This method renders a source bitmap into this device, much
        like the drawBitmap() method. The only difference is the
        additional mask parameter, which operates much like an
        additional clip mask: pixel with value zero in this mask
        result in destination pixel not being modified.

        @param rSrcBitmap
        Bitmap to render into this one. It is permitted that source
        and destination bitmap are the same.

        @param rMask
        Bitmap to use as a mask. Pixel with value != zero in this mask
        will result in destination pixel not being affected by the
        blit operation.

        @param rSrcRect
        Rectangle within the source bitmap to take the pixel from.

        @param rDstRect
        Rectangle in the destination bitmap to put the pixel
        into. Source and destination rectangle are permitted to have
        differing sizes; this method will scale the source pixel
        accordingly. Please note that both source and destination
        rectangle are interpreted excluding the rightmost pixel column
        and the bottommost pixel row, this is much like polygon
        filling. As a result, filling a given rectangle with
        fillPolyPolygon(), and using the same rectangle as the
        destination rectangle of this method, will affect exactly the
        same set of pixel.

        @param drawMode
        Draw mode to use when changing pixel values
     */
    void drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
                           const BitmapDeviceSharedPtr& rMask,
                           const basegfx::B2IRange&     rSrcRect,
                           const basegfx::B2IRange&     rDstRect,
                           DrawMode                     drawMode );

    /** Draw another bitmap through a mask into this device

        This method renders a source bitmap into this device, much
        like the drawBitmap() method. The only difference is the
        additional mask parameter, which operates much like an
        additional clip mask: pixel with value != zero in this mask
        result in destination pixel not being modified.

        @param rSrcBitmap
        Bitmap to render into this one. It is permitted that source
        and destination bitmap are the same.

        @param rMask
        Bitmap to use as a mask. Pixel with value != zero in this mask
        will result in destination pixel not being affected by the
        blit operation.

        @param rSrcRect
        Rectangle within the source bitmap to take the pixel from.

        @param rDstRect
        Rectangle in the destination bitmap to put the pixel
        into. Source and destination rectangle are permitted to have
        differing sizes; this method will scale the source pixel
        accordingly. Please note that both source and destination
        rectangle are interpreted excluding the rightmost pixel column
        and the bottommost pixel row, this is much like polygon
        filling. As a result, filling a given rectangle with
        fillPolyPolygon(), and using the same rectangle as the
        destination rectangle of this method, will affect exactly the
        same set of pixel.

        @param drawMode
        Draw mode to use when changing pixel values

        @param rClip
        Clip mask to use. Pixel where the corresponding clip mask
        pixel is 1 will not be modified.
     */
    void drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
                           const BitmapDeviceSharedPtr& rMask,
                           const basegfx::B2IRange&     rSrcRect,
                           const basegfx::B2IRange&     rDstRect,
                           DrawMode                     drawMode,
                           const BitmapDeviceSharedPtr& rClip );

protected:
    BitmapDevice( const basegfx::B2IRange&         rBounds,
                  sal_Int32                        nScanlineFormat,
                  sal_Int32                        nScanlineStride,
                  sal_uInt8*                       pFirstScanline,
                  const RawMemorySharedArray&      rMem,
                  const PaletteMemorySharedVector& rPalette );

    virtual ~BitmapDevice();

private:
    virtual bool isCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) const = 0;
    virtual bool isCompatibleClipMask( const BitmapDeviceSharedPtr& bmp ) const = 0;
    virtual bool isCompatibleAlphaMask( const BitmapDeviceSharedPtr& bmp ) const = 0;

    virtual void clear_i( Color                     fillColor,
                          const basegfx::B2IRange&  rBounds ) = 0;

    virtual void setPixel_i( const basegfx::B2IPoint& rPt,
                             Color                    lineColor,
                             DrawMode                 drawMode ) = 0;
    virtual void setPixel_i( const basegfx::B2IPoint&     rPt,
                             Color                        lineColor,
                             DrawMode                     drawMode,
                             const BitmapDeviceSharedPtr& rClip ) = 0;

    virtual Color getPixel_i( const basegfx::B2IPoint& rPt ) = 0;

    virtual sal_uInt32 getPixelData_i( const basegfx::B2IPoint& rPt ) = 0;

    virtual void drawLine_i( const basegfx::B2IPoint& rPt1,
                             const basegfx::B2IPoint& rPt2,
                             const basegfx::B2IRange& rBounds,
                             Color                    lineColor,
                             DrawMode                 drawMode ) = 0;
    virtual void drawLine_i( const basegfx::B2IPoint&     rPt1,
                             const basegfx::B2IPoint&     rPt2,
                             const basegfx::B2IRange&     rBounds,
                             Color                        lineColor,
                             DrawMode                     drawMode,
                             const BitmapDeviceSharedPtr& rClip ) = 0;

    virtual void drawPolygon_i( const basegfx::B2DPolygon& rPoly,
                                const basegfx::B2IRange&   rBounds,
                                Color                      lineColor,
                                DrawMode                   drawMode ) = 0;
    virtual void drawPolygon_i( const basegfx::B2DPolygon&   rPoly,
                                const basegfx::B2IRange&     rBounds,
                                Color                        lineColor,
                                DrawMode                     drawMode,
                                const BitmapDeviceSharedPtr& rClip ) = 0;

    virtual void fillPolyPolygon_i( const basegfx::B2DPolyPolygon& rPoly,
                                    Color                          fillColor,
                                    DrawMode                       drawMode,
                                    const basegfx::B2IRange&       rBounds ) = 0;
    virtual void fillPolyPolygon_i( const basegfx::B2DPolyPolygon& rPoly,
                                    Color                          fillColor,
                                    DrawMode                       drawMode,
                                    const basegfx::B2IRange&       rBounds,
                                    const BitmapDeviceSharedPtr&   rClip ) = 0;

    // must work with *this == rSrcBitmap!
    virtual void drawBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
                               const basegfx::B2IRange&     rSrcRect,
                               const basegfx::B2IRange&     rDstRect,
                               DrawMode                     drawMode ) = 0;
    virtual void drawBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
                               const basegfx::B2IRange&     rSrcRect,
                               const basegfx::B2IRange&     rDstRect,
                               DrawMode                     drawMode,
                               const BitmapDeviceSharedPtr& rClip ) = 0;

    // must work with *this == rSrcBitmap!
    virtual void drawMaskedColor_i( Color                        rSrcColor,
                                    const BitmapDeviceSharedPtr& rAlphaMask,
                                    const basegfx::B2IRange&     rSrcRect,
                                    const basegfx::B2IPoint&     rDstPoint ) = 0;
    virtual void drawMaskedColor_i( Color                        rSrcColor,
                                    const BitmapDeviceSharedPtr& rAlphaMask,
                                    const basegfx::B2IRange&     rSrcRect,
                                    const basegfx::B2IPoint&     rDstPoint,
                                    const BitmapDeviceSharedPtr& rClip ) = 0;

    // must work with *this == rSrcBitmap!
    virtual void drawMaskedBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
                                     const BitmapDeviceSharedPtr& rMask,
                                     const basegfx::B2IRange&     rSrcRect,
                                     const basegfx::B2IRange&     rDstRect,
                                     DrawMode                     drawMode ) = 0;
    virtual void drawMaskedBitmap_i( const BitmapDeviceSharedPtr& rSrcBitmap,
                                     const BitmapDeviceSharedPtr& rMask,
                                     const basegfx::B2IRange&     rSrcRect,
                                     const basegfx::B2IRange&     rDstRect,
                                     DrawMode                     drawMode,
                                     const BitmapDeviceSharedPtr& rClip ) = 0;

    BitmapDeviceSharedPtr getGenericRenderer() const;

    boost::scoped_ptr< ImplBitmapDevice > mpImpl;
};

/** Factory method to create a BitmapDevice for given scanline format
 */
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
                                          bool                      bTopDown,
                                          sal_Int32                 nScanlineFormat );

/** Factory method to create a BitmapDevice for given scanline format
    with the given palette

    Note: the provided palette must have sufficient size, to satisfy
    lookups for the whole range of pixel values from the specified
    format.
 */
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector&        rSize,
                                          bool                             bTopDown,
                                          sal_Int32                        nScanlineFormat,
                                          const PaletteMemorySharedVector& rPalette );

/** Factory method to create a BitmapDevice for given scanline format
    from the given piece of raw memory and palette

    Note: the provided memory must have sufficient size, to store the
    image of the specified area and format.
 */
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector&        rSize,
                                          bool                             bTopDown,
                                          sal_Int32                        nScanlineFormat,
                                          const RawMemorySharedArray&      rMem,
                                          const PaletteMemorySharedVector& rPalette );


/** Factory method to retrieve a subsetted BitmapDevice to the same
    memory.

    This method creates a second bitmap device instance, which renders
    to the same memory as the original, but to a limited, rectangular
    area. Useful to implement rectangular clips (usually faster than
    setting up a 1bpp clip mask).
 */
BitmapDeviceSharedPtr subsetBitmapDevice( const BitmapDeviceSharedPtr&     rProto,
                                          const basegfx::B2IRange&         rSubset );

/** Factory method to clone a BitmapDevice from a given prototype.

    All attributes (like scanline format and top-down state) are
    copied, only the size can be varied. Note that the prototype's
    bitmap content is <em>not</em> copied, only a palette (if any).
 */
BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector&        rSize,
                                         const BitmapDeviceSharedPtr&     rProto );

}

#endif /* INCLUDED_BASEBMP_BITMAPDEVICE_HXX */