Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / vcl / inc / win / salbmp.h
blobbedfbaed0948442eac469278a47bfed8ffbf0903
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _SV_SALBMP_H
21 #define _SV_SALBMP_H
23 #include <tools/gen.hxx>
24 #include <win/wincomp.hxx>
25 #include <salbmp.hxx>
26 #include <boost/shared_ptr.hpp>
28 // --------------
29 // - SalBitmap -
30 // --------------
32 struct BitmapBuffer;
33 class BitmapColor;
34 class BitmapPalette;
35 class SalGraphics;
36 namespace Gdiplus { class Bitmap; }
37 typedef boost::shared_ptr< Gdiplus::Bitmap > GdiPlusBmpPtr;
39 class WinSalBitmap : public SalBitmap
41 private:
42 friend class GdiPlusBuffer; // allow buffer to remove maGdiPlusBitmap and mpAssociatedAlpha eventually
44 Size maSize;
45 HGLOBAL mhDIB;
46 HBITMAP mhDDB;
48 // the buffered evtl. used Gdiplus::Bitmap instance. It is managed by
49 // GdiPlusBuffer. To make this safe, it is only handed out as shared
50 // pointer; the GdiPlusBuffer may delete the local instance.
52 // mpAssociatedAlpha holds the last WinSalBitmap used to construct an
53 // evtl. buffered GdiPlusBmp. This is needed since the GdiPlusBmp is a single
54 // instance and remembered only on the content-WinSalBitmap, not on the
55 // alpha-WinSalBitmap.
56 GdiPlusBmpPtr maGdiPlusBitmap;
57 const WinSalBitmap* mpAssociatedAlpha;
59 sal_uInt16 mnBitCount;
61 Gdiplus::Bitmap* ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
62 Gdiplus::Bitmap* ImplCreateGdiPlusBitmap();
64 public:
66 HGLOBAL ImplGethDIB() const { return mhDIB; }
67 HBITMAP ImplGethDDB() const { return mhDDB; }
69 GdiPlusBmpPtr ImplGetGdiPlusBitmap(const WinSalBitmap* pAlphaSource = 0) const;
71 static HGLOBAL ImplCreateDIB( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
72 static HANDLE ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB );
73 static sal_uInt16 ImplGetDIBColorCount( HGLOBAL hDIB );
74 static void ImplDecodeRLEBuffer( const BYTE* pSrcBuf, BYTE* pDstBuf,
75 const Size& rSizePixel, bool bRLE4 );
77 public:
79 WinSalBitmap();
80 virtual ~WinSalBitmap();
82 public:
84 bool Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle );
85 virtual bool Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
86 virtual bool Create( const SalBitmap& rSalBmpImpl );
87 virtual bool Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics );
88 virtual bool Create( const SalBitmap& rSalBmpImpl, sal_uInt16 nNewBitCount );
89 virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > xBitmapCanvas,
90 Size& rSize,
91 bool bMask = false );
93 virtual void Destroy();
95 virtual Size GetSize() const { return maSize; }
96 virtual sal_uInt16 GetBitCount() const { return mnBitCount; }
98 virtual BitmapBuffer* AcquireBuffer( bool bReadOnly );
99 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
100 virtual bool GetSystemData( BitmapSystemData& rData );
103 #endif // _SV_SALBMP_HXX
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */