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
30struct BitmapBuffer;
31class BitmapColor;
32class BitmapPalette;
33class SalGraphics;
34namespace Gdiplus { class Bitmap; }
35
37{
38private:
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
48public:
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
59public:
60
62 virtual ~WinSalBitmap() override;
63
64public:
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: */
BitmapAccessMode
std::shared_ptr< Gdiplus::Bitmap > ImplGetGdiPlusBitmap(const WinSalBitmap *pAlphaSource=nullptr) const
virtual bool Scale(const double &rScaleX, const double &rScaleY, BmpScaleFlag nScaleFlag) override
virtual BitmapBuffer * AcquireBuffer(BitmapAccessMode nMode) override
virtual sal_uInt16 GetBitCount() const override
Definition: win/salbmp.h:78
virtual ~WinSalBitmap() override
virtual bool Create(const SalBitmap &rSalBmpImpl, vcl::PixelFormat eNewPixelFormat) override
virtual bool Replace(const Color &rSearchColor, const Color &rReplaceColor, sal_uInt8 nTol) override
HBITMAP ImplGethDDB() const
Definition: win/salbmp.h:51
std::shared_ptr< Gdiplus::Bitmap > ImplCreateGdiPlusBitmap()
virtual bool Create(const SalBitmap &rSalBmpImpl) override
static HANDLE ImplCopyDIBOrDDB(HANDLE hHdl, bool bDIB)
std::shared_ptr< T > getSystemDependentData() const
Definition: win/salbmp.h:90
virtual void ReleaseBuffer(BitmapBuffer *pBuffer, BitmapAccessMode nMode) override
virtual void Destroy() override
virtual bool Create(const css::uno::Reference< css::rendering::XBitmapCanvas > &rBitmapCanvas, Size &rSize, bool bMask=false) override
virtual bool Create(const SalBitmap &rSalBmpImpl, SalGraphics *pGraphics) override
sal_uInt16 mnBitCount
Definition: win/salbmp.h:43
HGLOBAL mhDIB
Definition: win/salbmp.h:40
HGLOBAL ImplGethDIB() const
Definition: win/salbmp.h:50
virtual bool GetSystemData(BitmapSystemData &rData) override
std::shared_ptr< T > addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager &manager, Args &&... args) const
Definition: win/salbmp.h:96
static HGLOBAL ImplCreateDIB(const Size &rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette &rPal)
static sal_uInt16 ImplGetDIBColorCount(HGLOBAL hDIB)
HBITMAP mhDDB
Definition: win/salbmp.h:41
virtual Size GetSize() const override
Definition: win/salbmp.h:77
virtual bool Create(const Size &rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette &rPal) override
bool Create(HANDLE hBitmap)
std::shared_ptr< Gdiplus::Bitmap > ImplCreateGdiPlusBitmap(const WinSalBitmap &rAlphaSource)
virtual bool ScalingSupported() const override
void addOrReplaceSystemDependentData(SystemDependentData_SharedPtr &rData)
SystemDependentData_SharedPtr getSystemDependentData(size_t hash_code) const
rtl::Reference< ParseManager > manager
std::shared_ptr< SystemDependentData > SystemDependentData_SharedPtr
args
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:20
unsigned char sal_uInt8