LibreOffice Module vcl (master)  1
win/salbmp.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_INC_WIN_SALBMP_H
21 #define INCLUDED_VCL_INC_WIN_SALBMP_H
22 
23 #include <tools/gen.hxx>
24 #include <win/wincomp.hxx>
25 #include <salbmp.hxx>
27 #include <memory>
28 
29 
30 struct BitmapBuffer;
31 class BitmapColor;
32 class BitmapPalette;
33 class SalGraphics;
34 namespace Gdiplus { class Bitmap; }
35 
37 {
38 private:
40  HGLOBAL mhDIB;
41  HBITMAP mhDDB;
42 
43  sal_uInt16 mnBitCount;
44 
45  Gdiplus::Bitmap* ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
46  Gdiplus::Bitmap* ImplCreateGdiPlusBitmap();
47 
48 public:
49 
50  HGLOBAL ImplGethDIB() const { return mhDIB; }
51  HBITMAP ImplGethDDB() const { return mhDDB; }
52 
53  std::shared_ptr< Gdiplus::Bitmap > ImplGetGdiPlusBitmap(const WinSalBitmap* pAlphaSource = nullptr) const;
54 
55  static HGLOBAL ImplCreateDIB( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
56  static HANDLE ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB );
57  static sal_uInt16 ImplGetDIBColorCount( HGLOBAL hDIB );
58  static void ImplDecodeRLEBuffer( const BYTE* pSrcBuf, BYTE* pDstBuf,
59  const Size& rSizePixel, bool bRLE4 );
60 
61 public:
62 
63  WinSalBitmap();
64  virtual ~WinSalBitmap() override;
65 
66 public:
67 
68  bool Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle );
69  virtual bool Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ) override;
70  virtual bool Create( const SalBitmap& rSalBmpImpl ) override;
71  virtual bool Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics ) override;
72  virtual bool Create( const SalBitmap& rSalBmpImpl, sal_uInt16 nNewBitCount ) override;
73  virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
74  Size& rSize,
75  bool bMask = false ) override;
76 
77  virtual void Destroy() override;
78 
79  virtual Size GetSize() const override { return maSize; }
80  virtual sal_uInt16 GetBitCount() const override { return mnBitCount; }
81 
82  virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
83  virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
84  virtual bool GetSystemData( BitmapSystemData& rData ) override;
85 
86  virtual bool ScalingSupported() const override;
87  virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
88  virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override;
89 
90  // exclusive management op's for SystemDependentData at WinSalBitmap
91  template<class T>
92  std::shared_ptr<T> getSystemDependentData() const
93  {
94  return std::static_pointer_cast<T>(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code()));
95  }
96 
97  template<class T, class... Args>
98  std::shared_ptr<T> addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const
99  {
100  std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
103  return r;
104  }
105 };
106 
107 #endif // INCLUDED_VCL_INC_WIN_SALBMP_H
108 
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Gdiplus::Bitmap * ImplCreateGdiPlusBitmap()
static sal_uInt16 ImplGetDIBColorCount(HGLOBAL hDIB)
virtual void Destroy() override
static HANDLE ImplCopyDIBOrDDB(HANDLE hHdl, bool bDIB)
virtual bool Scale(const double &rScaleX, const double &rScaleY, BmpScaleFlag nScaleFlag) override
virtual Size GetSize() const override
Definition: win/salbmp.h:79
virtual sal_uInt16 GetBitCount() const override
Definition: win/salbmp.h:80
unsigned char BYTE
tuple args
HGLOBAL ImplGethDIB() const
Definition: win/salbmp.h:50
void addOrReplaceSystemDependentData(SystemDependentData_SharedPtr &rData)
std::shared_ptr< T > addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager &manager, Args &&...args) const
Definition: win/salbmp.h:98
static void ImplDecodeRLEBuffer(const BYTE *pSrcBuf, BYTE *pDstBuf, const Size &rSizePixel, bool bRLE4)
virtual void ReleaseBuffer(BitmapBuffer *pBuffer, BitmapAccessMode nMode) override
HBITMAP ImplGethDDB() const
Definition: win/salbmp.h:51
BitmapAccessMode
BmpScaleFlag
Definition: bitmap.hxx:48
virtual BitmapBuffer * AcquireBuffer(BitmapAccessMode nMode) override
virtual ~WinSalBitmap() override
std::shared_ptr< Gdiplus::Bitmap > ImplGetGdiPlusBitmap(const WinSalBitmap *pAlphaSource=nullptr) const
std::shared_ptr< T > getSystemDependentData() const
Definition: win/salbmp.h:92
sal_uInt16 mnBitCount
Definition: win/salbmp.h:43
virtual bool Replace(const Color &rSearchColor, const Color &rReplaceColor, sal_uInt8 nTol) override
unsigned char sal_uInt8
HGLOBAL mhDIB
Definition: win/salbmp.h:40
HBITMAP mhDDB
Definition: win/salbmp.h:41
virtual bool ScalingSupported() const override
static HGLOBAL ImplCreateDIB(const Size &rSize, sal_uInt16 nBitCount, const BitmapPalette &rPal)
bool Create(HANDLE hBitmap, bool bDIB, bool bCopyHandle)
SystemDependentData_SharedPtr getSystemDependentData(size_t hash_code) const
std::shared_ptr< SystemDependentData > SystemDependentData_SharedPtr
virtual bool GetSystemData(BitmapSystemData &rData) override