1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FXGE_WIN32_CFX_WINDOWSDIB_H_ 8 #define CORE_FXGE_WIN32_CFX_WINDOWSDIB_H_ 9 10 #include <windows.h> 11 12 #include "core/fxcrt/bytestring.h" 13 #include "core/fxge/dib/cfx_dibitmap.h" 14 15 #define WINDIB_OPEN_MEMORY 0x1 16 #define WINDIB_OPEN_PATHNAME 0x2 17 18 struct WINDIB_Open_Args_ { 19 int flags; 20 const uint8_t* memory_base; 21 size_t memory_size; 22 const wchar_t* path_name; 23 }; 24 25 class CFX_WindowsDIB final : public CFX_DIBitmap { 26 public: 27 template <typename T, typename... Args> 28 friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); 29 30 static ByteString GetBitmapInfo(const RetainPtr<CFX_DIBitmap>& pBitmap); 31 static HBITMAP GetDDBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap, HDC hDC); 32 33 static RetainPtr<CFX_DIBitmap> LoadFromBuf(BITMAPINFO* pbmi, void* pData); 34 static RetainPtr<CFX_DIBitmap> LoadFromFile(const wchar_t* filename); 35 static RetainPtr<CFX_DIBitmap> LoadFromFile(const char* filename); 36 static RetainPtr<CFX_DIBitmap> LoadDIBitmap(WINDIB_Open_Args_ args); 37 GetWindowsBitmap()38 HBITMAP GetWindowsBitmap() const { return m_hBitmap; } 39 40 void LoadFromDevice(HDC hDC, int left, int top); 41 void SetToDevice(HDC hDC, int left, int top); 42 43 private: 44 CFX_WindowsDIB(HDC hDC, int width, int height); 45 ~CFX_WindowsDIB() override; 46 47 HDC m_hMemDC; 48 HBITMAP m_hBitmap; 49 HBITMAP m_hOldBitmap; 50 }; 51 52 #endif // CORE_FXGE_WIN32_CFX_WINDOWSDIB_H_ 53