1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_WIN_SALBMP_H
21 #define INCLUDED_VCL_INC_WIN_SALBMP_H
23 #include <tools/gen.hxx>
24 #include <win/wincomp.hxx>
26 #include <boost/shared_ptr.hpp>
34 namespace Gdiplus
{ class Bitmap
; }
35 typedef boost::shared_ptr
< Gdiplus::Bitmap
> GdiPlusBmpPtr
;
37 class WinSalBitmap
: public SalBitmap
40 friend class GdiPlusBuffer
; // allow buffer to remove maGdiPlusBitmap and mpAssociatedAlpha eventually
46 // the buffered evtl. used Gdiplus::Bitmap instance. It is managed by
47 // GdiPlusBuffer. To make this safe, it is only handed out as shared
48 // pointer; the GdiPlusBuffer may delete the local instance.
50 // mpAssociatedAlpha holds the last WinSalBitmap used to construct an
51 // evtl. buffered GdiPlusBmp. This is needed since the GdiPlusBmp is a single
52 // instance and remembered only on the content-WinSalBitmap, not on the
53 // alpha-WinSalBitmap.
54 GdiPlusBmpPtr maGdiPlusBitmap
;
55 const WinSalBitmap
* mpAssociatedAlpha
;
57 sal_uInt16 mnBitCount
;
59 Gdiplus::Bitmap
* ImplCreateGdiPlusBitmap(const WinSalBitmap
& rAlphaSource
);
60 Gdiplus::Bitmap
* ImplCreateGdiPlusBitmap();
64 HGLOBAL
ImplGethDIB() const { return mhDIB
; }
65 HBITMAP
ImplGethDDB() const { return mhDDB
; }
67 GdiPlusBmpPtr
ImplGetGdiPlusBitmap(const WinSalBitmap
* pAlphaSource
= 0) const;
69 static HGLOBAL
ImplCreateDIB( const Size
& rSize
, sal_uInt16 nBitCount
, const BitmapPalette
& rPal
);
70 static HANDLE
ImplCopyDIBOrDDB( HANDLE hHdl
, bool bDIB
);
71 static sal_uInt16
ImplGetDIBColorCount( HGLOBAL hDIB
);
72 static void ImplDecodeRLEBuffer( const BYTE
* pSrcBuf
, BYTE
* pDstBuf
,
73 const Size
& rSizePixel
, bool bRLE4
);
78 virtual ~WinSalBitmap();
82 bool Create( HANDLE hBitmap
, bool bDIB
, bool bCopyHandle
);
83 virtual bool Create( const Size
& rSize
, sal_uInt16 nBitCount
, const BitmapPalette
& rPal
) SAL_OVERRIDE
;
84 virtual bool Create( const SalBitmap
& rSalBmpImpl
) SAL_OVERRIDE
;
85 virtual bool Create( const SalBitmap
& rSalBmpImpl
, SalGraphics
* pGraphics
) SAL_OVERRIDE
;
86 virtual bool Create( const SalBitmap
& rSalBmpImpl
, sal_uInt16 nNewBitCount
) SAL_OVERRIDE
;
87 virtual bool Create( const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBitmapCanvas
>& rBitmapCanvas
,
89 bool bMask
= false ) SAL_OVERRIDE
;
91 virtual void Destroy() SAL_OVERRIDE
;
93 virtual Size
GetSize() const SAL_OVERRIDE
{ return maSize
; }
94 virtual sal_uInt16
GetBitCount() const SAL_OVERRIDE
{ return mnBitCount
; }
96 virtual BitmapBuffer
* AcquireBuffer( BitmapAccessMode nMode
) SAL_OVERRIDE
;
97 virtual void ReleaseBuffer( BitmapBuffer
* pBuffer
, BitmapAccessMode nMode
) SAL_OVERRIDE
;
98 virtual bool GetSystemData( BitmapSystemData
& rData
) SAL_OVERRIDE
;
100 virtual bool Crop( const Rectangle
& rRectPixel
) SAL_OVERRIDE
;
101 virtual bool Erase( const Color
& rFillColor
) SAL_OVERRIDE
;
102 virtual bool Scale( const double& rScaleX
, const double& rScaleY
, BmpScaleFlag nScaleFlag
) SAL_OVERRIDE
;
103 virtual bool Replace( const Color
& rSearchColor
, const Color
& rReplaceColor
, sal_uLong nTol
) SAL_OVERRIDE
;
106 #endif // INCLUDED_VCL_INC_WIN_SALBMP_H
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */