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