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  std::shared_ptr<Gdiplus::Bitmap> ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
46  std::shared_ptr<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, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal );
56  static HANDLE ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB );
57  static sal_uInt16 ImplGetDIBColorCount( HGLOBAL hDIB );
58 
59 public:
60 
61  WinSalBitmap();
62  virtual ~WinSalBitmap() override;
63 
64 public:
65 
66  bool Create( HANDLE hBitmap );
67  virtual bool Create( const Size& rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette& rPal ) override;
68  virtual bool Create( const SalBitmap& rSalBmpImpl ) override;
69  virtual bool Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics ) override;
70  virtual bool Create( const SalBitmap& rSalBmpImpl, vcl::PixelFormat eNewPixelFormat ) override;
71  virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
72  Size& rSize,
73  bool bMask = false ) override;
74 
75  virtual void Destroy() override;
76 
77  virtual Size GetSize() const override { return maSize; }
78  virtual sal_uInt16 GetBitCount() const override { return mnBitCount; }
79 
80  virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
81  virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
82  virtual bool GetSystemData( BitmapSystemData& rData ) override;
83 
84  virtual bool ScalingSupported() const override;
85  virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
86  virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override;
87 
88  // exclusive management op's for SystemDependentData at WinSalBitmap
89  template<class T>
90  std::shared_ptr<T> getSystemDependentData() const
91  {
92  return std::static_pointer_cast<T>(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code()));
93  }
94 
95  template<class T, class... Args>
96  std::shared_ptr<T> addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const
97  {
98  std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
99 
100  // tdf#129845 only add to buffer if a relevant buffer time is estimated
101  if(r->calculateCombinedHoldCyclesInSeconds() > 0)
102  {
105  }
106 
107  return r;
108  }
109 };
110 
111 #endif // INCLUDED_VCL_INC_WIN_SALBMP_H
112 
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:19
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:77
virtual sal_uInt16 GetBitCount() const override
Definition: win/salbmp.h:78
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:96
std::shared_ptr< Gdiplus::Bitmap > ImplCreateGdiPlusBitmap()
virtual void ReleaseBuffer(BitmapBuffer *pBuffer, BitmapAccessMode nMode) override
HBITMAP ImplGethDDB() const
Definition: win/salbmp.h:51
BitmapAccessMode
bool Create(HANDLE hBitmap)
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:90
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, vcl::PixelFormat ePixelFormat, const BitmapPalette &rPal)
SystemDependentData_SharedPtr getSystemDependentData(size_t hash_code) const
std::shared_ptr< SystemDependentData > SystemDependentData_SharedPtr
virtual bool GetSystemData(BitmapSystemData &rData) override