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>
33 namespace Gdiplus
{ class Bitmap
; }
35 class WinSalBitmap
: public SalBitmap
38 friend class GdiPlusBuffer
; // allow buffer to remove maGdiPlusBitmap and mpAssociatedAlpha eventually
44 // the buffered evtl. used Gdiplus::Bitmap instance. It is managed by
45 // GdiPlusBuffer. To make this safe, it is only handed out as shared
46 // pointer; the GdiPlusBuffer may delete the local instance.
48 // mpAssociatedAlpha holds the last WinSalBitmap used to construct an
49 // evtl. buffered GdiPlusBmp. This is needed since the GdiPlusBmp is a single
50 // instance and remembered only on the content-WinSalBitmap, not on the
51 // alpha-WinSalBitmap.
52 std::shared_ptr
< Gdiplus::Bitmap
> maGdiPlusBitmap
;
53 const WinSalBitmap
* mpAssociatedAlpha
;
55 sal_uInt16 mnBitCount
;
57 Gdiplus::Bitmap
* ImplCreateGdiPlusBitmap(const WinSalBitmap
& rAlphaSource
);
58 Gdiplus::Bitmap
* ImplCreateGdiPlusBitmap();
62 HGLOBAL
ImplGethDIB() const { return mhDIB
; }
63 HBITMAP
ImplGethDDB() const { return mhDDB
; }
65 std::shared_ptr
< Gdiplus::Bitmap
> ImplGetGdiPlusBitmap(const WinSalBitmap
* pAlphaSource
= nullptr) const;
67 static HGLOBAL
ImplCreateDIB( const Size
& rSize
, sal_uInt16 nBitCount
, const BitmapPalette
& rPal
);
68 static HANDLE
ImplCopyDIBOrDDB( HANDLE hHdl
, bool bDIB
);
69 static sal_uInt16
ImplGetDIBColorCount( HGLOBAL hDIB
);
70 static void ImplDecodeRLEBuffer( const BYTE
* pSrcBuf
, BYTE
* pDstBuf
,
71 const Size
& rSizePixel
, bool bRLE4
);
76 virtual ~WinSalBitmap() override
;
80 bool Create( HANDLE hBitmap
, bool bDIB
, bool bCopyHandle
);
81 virtual bool Create( const Size
& rSize
, sal_uInt16 nBitCount
, const BitmapPalette
& rPal
) override
;
82 virtual bool Create( const SalBitmap
& rSalBmpImpl
) override
;
83 virtual bool Create( const SalBitmap
& rSalBmpImpl
, SalGraphics
* pGraphics
) override
;
84 virtual bool Create( const SalBitmap
& rSalBmpImpl
, sal_uInt16 nNewBitCount
) override
;
85 virtual bool Create( const css::uno::Reference
< css::rendering::XBitmapCanvas
>& rBitmapCanvas
,
87 bool bMask
= false ) override
;
89 virtual void Destroy() override
;
91 virtual Size
GetSize() const override
{ return maSize
; }
92 virtual sal_uInt16
GetBitCount() const override
{ return mnBitCount
; }
94 virtual BitmapBuffer
* AcquireBuffer( BitmapAccessMode nMode
) override
;
95 virtual void ReleaseBuffer( BitmapBuffer
* pBuffer
, BitmapAccessMode nMode
) override
;
96 virtual bool GetSystemData( BitmapSystemData
& rData
) override
;
98 virtual bool ScalingSupported() const override
;
99 virtual bool Scale( const double& rScaleX
, const double& rScaleY
, BmpScaleFlag nScaleFlag
) override
;
100 virtual bool Replace( const Color
& rSearchColor
, const Color
& rReplaceColor
, sal_uLong nTol
) override
;
103 #endif // INCLUDED_VCL_INC_WIN_SALBMP_H
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */