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_INCLUDE_FXGE_FX_GE_WIN32_H_ 8 #define CORE_INCLUDE_FXGE_FX_GE_WIN32_H_ 9 10 #ifdef _WIN32 11 #ifndef _WINDOWS_ 12 #include <windows.h> 13 #endif 14 #define WINDIB_OPEN_MEMORY 0x1 15 #define WINDIB_OPEN_PATHNAME 0x2 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 class CFX_WindowsDIB : public CFX_DIBitmap { 26 public: 27 static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap); 28 29 static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData); 30 31 static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC); 32 33 static CFX_DIBitmap* LoadFromDDB(HDC hDC, 34 HBITMAP hBitmap, 35 FX_DWORD* pPalette = NULL, 36 FX_DWORD size = 256); 37 38 static CFX_DIBitmap* LoadFromFile(const FX_WCHAR* filename); 39 40 static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename) { 41 return LoadFromFile(CFX_WideString::FromLocal(filename).c_str()); 42 } 43 44 static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args); 45 46 CFX_WindowsDIB(HDC hDC, int width, int height); 47 48 ~CFX_WindowsDIB(); 49 50 HDC GetDC() const { return m_hMemDC; } 51 52 HBITMAP GetWindowsBitmap() const { return m_hBitmap; } 53 54 void LoadFromDevice(HDC hDC, int left, int top); 55 56 void SetToDevice(HDC hDC, int left, int top); 57 58 protected: 59 HDC m_hMemDC; 60 61 HBITMAP m_hBitmap; 62 63 HBITMAP m_hOldBitmap; 64 }; 65 class CFX_WindowsDevice : public CFX_RenderDevice { 66 public: 67 static IFX_RenderDeviceDriver* CreateDriver(HDC hDC, 68 FX_BOOL bCmykOutput = FALSE); 69 70 CFX_WindowsDevice(HDC hDC, 71 FX_BOOL bCmykOutput = FALSE, 72 FX_BOOL bForcePSOutput = FALSE, 73 int psLevel = 2); 74 75 HDC GetDC() const; 76 77 FX_BOOL m_bForcePSOutput; 78 79 static int m_psLevel; 80 }; 81 class CFX_WinBitmapDevice : public CFX_RenderDevice { 82 public: 83 CFX_WinBitmapDevice(int width, int height, FXDIB_Format format); 84 85 ~CFX_WinBitmapDevice(); 86 87 HDC GetDC() { return m_hDC; } 88 89 protected: 90 HBITMAP m_hBitmap; 91 92 HBITMAP m_hOldBitmap; 93 94 HDC m_hDC; 95 }; 96 #endif 97 98 #endif // CORE_INCLUDE_FXGE_FX_GE_WIN32_H_ 99