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 #ifdef _WIN32 10 #ifndef _WINDOWS_ 11 #include <windows.h> 12 #endif 13 #define WINDIB_OPEN_MEMORY 0x1 14 #define WINDIB_OPEN_PATHNAME 0x2 15 16 typedef struct WINDIB_Open_Args_ { 17 int flags; 18 19 const uint8_t* memory_base; 20 21 size_t memory_size; 22 23 const FX_WCHAR* path_name; 24 } WINDIB_Open_Args_; 25 26 class CFX_WindowsDIB : public CFX_DIBitmap { 27 public: 28 CFX_WindowsDIB(HDC hDC, int width, int height); 29 ~CFX_WindowsDIB() override; 30 31 static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap); 32 static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData); 33 static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC); 34 static CFX_DIBitmap* LoadFromFile(const FX_WCHAR* filename); 35 static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename); 36 static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); 37 GetDC()38 HDC GetDC() const { return m_hMemDC; } GetWindowsBitmap()39 HBITMAP GetWindowsBitmap() const { return m_hBitmap; } 40 41 void LoadFromDevice(HDC hDC, int left, int top); 42 void SetToDevice(HDC hDC, int left, int top); 43 44 protected: 45 HDC m_hMemDC; 46 HBITMAP m_hBitmap; 47 HBITMAP m_hOldBitmap; 48 }; 49 50 #endif // _WIN32 51 52 #endif // CORE_FXGE_WIN32_CFX_WINDOWSDIB_H_ 53