Home | History | Annotate | Download | only in fxge
      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 
     18     int         flags;
     19 
     20     const FX_BYTE*  memory_base;
     21 
     22     size_t    memory_size;
     23 
     24     FX_LPCWSTR  path_name;
     25 } WINDIB_Open_Args_;
     26 class CFX_WindowsDIB : public CFX_DIBitmap
     27 {
     28 public:
     29 
     30     static CFX_ByteString	GetBitmapInfo(const CFX_DIBitmap* pBitmap);
     31 
     32     static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData);
     33 
     34     static HBITMAP		GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC);
     35 
     36     static CFX_DIBitmap* LoadFromDDB(HDC hDC, HBITMAP hBitmap, FX_DWORD* pPalette = NULL, FX_DWORD size = 256);
     37 
     38     static CFX_DIBitmap* LoadFromFile(FX_LPCWSTR filename);
     39 
     40     static CFX_DIBitmap* LoadFromFile(FX_LPCSTR filename)
     41     {
     42         return LoadFromFile(CFX_WideString::FromLocal(filename).c_str());
     43     }
     44 
     45     static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args);
     46 
     47     CFX_WindowsDIB(HDC hDC, int width, int height);
     48 
     49     ~CFX_WindowsDIB();
     50 
     51     HDC					GetDC() const
     52     {
     53         return m_hMemDC;
     54     }
     55 
     56     HBITMAP				GetWindowsBitmap() const
     57     {
     58         return m_hBitmap;
     59     }
     60 
     61     void				LoadFromDevice(HDC hDC, int left, int top);
     62 
     63     void				SetToDevice(HDC hDC, int left, int top);
     64 protected:
     65 
     66     HDC					m_hMemDC;
     67 
     68     HBITMAP				m_hBitmap;
     69 
     70     HBITMAP				m_hOldBitmap;
     71 };
     72 class CFX_WindowsDevice : public CFX_RenderDevice
     73 {
     74 public:
     75     static IFX_RenderDeviceDriver*	CreateDriver(HDC hDC, FX_BOOL bCmykOutput = FALSE);
     76 
     77     CFX_WindowsDevice(HDC hDC, FX_BOOL bCmykOutput = FALSE, FX_BOOL bForcePSOutput = FALSE, int psLevel = 2);
     78 
     79     HDC		GetDC() const;
     80 
     81     FX_BOOL m_bForcePSOutput;
     82 
     83     static int m_psLevel;
     84 };
     85 class CFX_WinBitmapDevice : public CFX_RenderDevice
     86 {
     87 public:
     88 
     89     CFX_WinBitmapDevice(int width, int height, FXDIB_Format format);
     90 
     91     ~CFX_WinBitmapDevice();
     92 
     93     HDC		GetDC()
     94     {
     95         return m_hDC;
     96     }
     97 protected:
     98 
     99     HBITMAP	m_hBitmap;
    100 
    101     HBITMAP m_hOldBitmap;
    102 
    103     HDC		m_hDC;
    104 };
    105 #endif
    106 
    107 #endif  // CORE_INCLUDE_FXGE_FX_GE_WIN32_H_
    108