Home | History | Annotate | Download | only in win32
      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 
     14 #include "core/fxcrt/bytestring.h"
     15 #include "core/fxge/dib/cfx_dibitmap.h"
     16 
     17 #define WINDIB_OPEN_MEMORY 0x1
     18 #define WINDIB_OPEN_PATHNAME 0x2
     19 
     20 typedef struct WINDIB_Open_Args_ {
     21   int flags;
     22 
     23   const uint8_t* memory_base;
     24 
     25   size_t memory_size;
     26 
     27   const wchar_t* path_name;
     28 } WINDIB_Open_Args_;
     29 
     30 class CFX_WindowsDIB : public CFX_DIBitmap {
     31  public:
     32   template <typename T, typename... Args>
     33   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
     34 
     35   ~CFX_WindowsDIB() override;
     36 
     37   static ByteString GetBitmapInfo(const RetainPtr<CFX_DIBitmap>& pBitmap);
     38   static HBITMAP GetDDBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap, HDC hDC);
     39 
     40   static RetainPtr<CFX_DIBitmap> LoadFromBuf(BITMAPINFO* pbmi, void* pData);
     41   static RetainPtr<CFX_DIBitmap> LoadFromFile(const wchar_t* filename);
     42   static RetainPtr<CFX_DIBitmap> LoadFromFile(const char* filename);
     43   static RetainPtr<CFX_DIBitmap> LoadDIBitmap(WINDIB_Open_Args_ args);
     44 
     45   HBITMAP GetWindowsBitmap() const { return m_hBitmap; }
     46 
     47   void LoadFromDevice(HDC hDC, int left, int top);
     48   void SetToDevice(HDC hDC, int left, int top);
     49 
     50  protected:
     51   CFX_WindowsDIB(HDC hDC, int width, int height);
     52 
     53   HDC m_hMemDC;
     54   HBITMAP m_hBitmap;
     55   HBITMAP m_hOldBitmap;
     56 };
     57 
     58 #endif  // _WIN32
     59 
     60 #endif  // CORE_FXGE_WIN32_CFX_WINDOWSDIB_H_
     61