home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectInput / DIConfig / cbitmap.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  2.7 KB  |  76 lines

  1. //-----------------------------------------------------------------------------
  2. // File: Cbitmap.h
  3. //
  4. // Desc: CBitmap class is an object that wraps around a Windows bitmap.
  5. //
  6. // Copyright (C) 1999-2001 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8.  
  9. #ifndef __CBITMAP_H__
  10. #define __CBITMAP_H__
  11.  
  12.  
  13. class CBitmap
  14. {
  15. private:
  16.     CBitmap() :
  17.         m_hbm(NULL),
  18.         m_bSizeKnown(FALSE),
  19.         m_hDCInto(NULL), m_hOldBitmap(NULL)
  20.     {}
  21. public:
  22.     ~CBitmap();
  23.  
  24.     static CBitmap *CreateViaD3DX(LPCTSTR tszFileName, LPDIRECT3DSURFACE8 pUISurf = NULL);
  25.     static CBitmap *CreateViaLoadImage(HINSTANCE hInst, LPCTSTR tszName, UINT uType, int cx, int cy, UINT fuLoad);
  26.     static CBitmap *CreateFromResource(HINSTANCE hInst, UINT uID) {return CreateFromResource(hInst, MAKEINTRESOURCE(uID));}
  27.     static CBitmap *CreateFromResource(HINSTANCE hInst, LPCTSTR tszName);
  28.     static CBitmap *CreateFromFile(LPCTSTR tszFileName);
  29.     static CBitmap *StealToCreate(HBITMAP &refbm);
  30.     static CBitmap *Create(int cx, int cy, HDC hDC = NULL) {SIZE size = {cx, cy}; return Create(size, hDC);}
  31.     static CBitmap *Create(SIZE, HDC = NULL);
  32.     static CBitmap *Create(SIZE, COLORREF, HDC = NULL);
  33.     static CBitmap *CreateHorzGradient(const RECT &, COLORREF, COLORREF);
  34.  
  35.     BOOL GetSize(SIZE *psize);
  36.     void AssumeSize(SIZE size);
  37.     BOOL FigureSize();
  38.  
  39.     CBitmap *CreateResizedTo(SIZE size, HDC hDC = NULL, int iStretchMode = HALFTONE, BOOL bStretch = TRUE);
  40.     CBitmap *Dup();
  41.     
  42.     BOOL Get(HDC hDC, POINT point, SIZE size);
  43.     BOOL Get(HDC hDC, POINT point);
  44.  
  45.     BOOL Draw(HDC hDC) {return Draw(hDC, 0, 0);}
  46.     BOOL Draw(HDC hDC, SIZE size) {return Draw(hDC, 0, 0, size);}
  47.     BOOL Draw(HDC hDC, int x, int y, SIZE size) {POINT t = {x, y}; return Draw(hDC, t, size);}
  48.     BOOL Draw(HDC hDC, int x, int y) {POINT t = {x, y}; return Draw(hDC, t);}
  49.     BOOL Draw(HDC hDC, POINT origin) {SIZE t = {0, 0}; return Draw(hDC, origin, t, TRUE);}
  50.     BOOL Draw(HDC hDC, POINT origin, SIZE size, BOOL bAll = FALSE);
  51.  
  52.     BOOL Blend(HDC hDC) {return Blend(hDC, 0, 0);}
  53.     BOOL Blend(HDC hDC, SIZE size) {return Blend(hDC, 0, 0, size);}
  54.     BOOL Blend(HDC hDC, int x, int y, SIZE size) {POINT t = {x, y}; return Blend(hDC, t, size);}
  55.     BOOL Blend(HDC hDC, int x, int y) {POINT t = {x, y}; return Blend(hDC, t);}
  56.     BOOL Blend(HDC hDC, POINT origin) {SIZE t = {0, 0}; return Blend(hDC, origin, t, TRUE);}
  57.     BOOL Blend(HDC hDC, POINT origin, SIZE size, BOOL bAll = FALSE);
  58.  
  59.     HDC BeginPaintInto(HDC hCDC = NULL);
  60.     void EndPaintInto(HDC &hDC);
  61.  
  62.     BOOL MapToDC(HDC hDCTo, HDC hDCMapFrom = NULL);
  63.  
  64. private:
  65.     HBITMAP m_hbm;
  66.     SIZE m_size;
  67.     BOOL m_bSizeKnown;
  68.     HDC m_hDCInto;
  69.     HGDIOBJ m_hOldBitmap;
  70.     void PopOut();
  71.     void PopIn();
  72. };
  73.  
  74.  
  75. #endif //__CBITMAP_H__
  76.