home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap16 / Dibble / DibHelp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  3.7 KB  |  87 lines

  1. /*-------------------------------------
  2.    DIBHELP.H header file for DIBHELP.C
  3.   -------------------------------------*/
  4.  
  5. typedef void * HDIB ;
  6.  
  7.      // Functions in DIBHELP.C
  8.  
  9. BOOL DibIsValid (HDIB hdib) ;
  10. HBITMAP DibBitmapHandle (HDIB hdib) ;
  11. int DibWidth (HDIB hdib) ;
  12. int DibHeight (HDIB hdib) ;
  13. int DibBitCount (HDIB hdib) ;
  14. int DibRowLength (HDIB hdib) ;
  15. int DibNumColors (HDIB hdib) ;
  16. DWORD DibMask (HDIB hdib, int i) ;
  17. int DibRShift (HDIB hdib, int i) ;
  18. int DibLShift (HDIB hdib, int i) ;
  19. int DibCompression (HDIB hdib) ;
  20. BOOL DibIsAddressable (HDIB hdib) ;
  21. DWORD DibInfoHeaderSize (HDIB hdib) ;
  22. DWORD DibMaskSize (HDIB hdib) ;
  23. DWORD DibColorSize (HDIB hdib) ;
  24. DWORD DibInfoSize (HDIB hdib) ;
  25. DWORD DibBitsSize (HDIB hdib) ;
  26. DWORD DibTotalSize (HDIB hdib) ;
  27. BITMAPINFOHEADER * DibInfoHeaderPtr (HDIB hdib) ;
  28. DWORD * DibMaskPtr (HDIB hdib) ;
  29. void * DibBitsPtr (HDIB hdib) ;
  30. BOOL DibGetColor (HDIB hdib, int index, RGBQUAD * prgb) ;
  31. BOOL DibSetColor (HDIB hdib, int index, RGBQUAD * prgb) ;
  32. BYTE * DibPixelPtr (HDIB hdib, int x, int y) ;
  33. DWORD DibGetPixel (HDIB hdib, int x, int y) ;
  34. BOOL DibSetPixel (HDIB hdib, int x, int y, DWORD dwPixel) ;
  35. BOOL DibGetPixelColor (HDIB hdib, int x, int y, RGBQUAD * prgb) ;
  36. BOOL DibSetPixelColor (HDIB hdib, int x, int y, RGBQUAD * prgb) ;
  37. HDIB DibCreateFromInfo (BITMAPINFO * pbmi) ;
  38. BOOL DibDelete (HDIB hdib) ;
  39. HDIB DibCreate (int cx, int cy, int cBits, int cColors) ;
  40. HDIB DibCopy (HDIB hdibSrc, BOOL fRotate) ;
  41. BITMAPINFO * DibCopyToPackedDib (HDIB hdib, BOOL fUseGlobal) ;
  42. HDIB DibCopyFromPackedDib (BITMAPINFO * pPackedDib) ;
  43. HDIB DibFileLoad (const TCHAR * szFileName) ;
  44. BOOL DibFileSave (HDIB hdib, const TCHAR * szFileName) ;
  45. HBITMAP DibCopyToDdb (HDIB hdib, HWND hwnd, HPALETTE hPalette) ;
  46. HDIB DibCreateFromDdb (HBITMAP hBitmap) ;
  47.  
  48. /*-----------------------------------------------
  49.    Quickie no-bounds-checked pixel gets and sets
  50.   -----------------------------------------------*/
  51.  
  52. #define DibPixelPtr1(hdib, x, y)  (((* (PBYTE **) hdib) [y]) + ((x) >> 3))
  53. #define DibPixelPtr4(hdib, x, y)  (((* (PBYTE **) hdib) [y]) + ((x) >> 1))
  54. #define DibPixelPtr8(hdib, x, y)  (((* (PBYTE **) hdib) [y]) +  (x)      )
  55. #define DibPixelPtr16(hdib, x, y)  \
  56.                         ((WORD *) (((* (PBYTE **) hdib) [y]) +  (x) *  2))
  57.  
  58. #define DibPixelPtr24(hdib, x, y)  \
  59.                    ((RGBTRIPLE *) (((* (PBYTE **) hdib) [y]) +  (x) *  3))
  60.  
  61. #define DibPixelPtr32(hdib, x, y)  \
  62.                        ((DWORD *) (((* (PBYTE **) hdib) [y]) +  (x) *  4))
  63.  
  64. #define DibGetPixel1(hdib, x, y)   \
  65.                (0x01 & (* DibPixelPtr1 (hdib, x, y) >> (7 - ((x) & 7))))
  66.  
  67. #define DibGetPixel4(hdib, x, y)   \
  68.                (0x0F & (* DibPixelPtr4 (hdib, x, y) >> ((x) & 1 ? 0 : 4)))
  69.  
  70. #define DibGetPixel8(hdib, x, y)     (* DibPixelPtr8  (hdib, x, y))
  71. #define DibGetPixel16(hdib, x, y)    (* DibPixelPtr16 (hdib, x, y))
  72. #define DibGetPixel24(hdib, x, y)    (* DibPixelPtr24 (hdib, x, y))
  73. #define DibGetPixel32(hdib, x, y)    (* DibPixelPtr32(hdib, x, y))
  74.  
  75. #define DibSetPixel1(hdib, x, y, p)                                        \
  76.           ((* DibPixelPtr1 (hdib, x, y) &= ~( 1  << (7 - ((x) & 7)))),     \
  77.            (* DibPixelPtr1 (hdib, x, y) |=  ((p) << (7 - ((x) & 7)))))
  78.  
  79. #define DibSetPixel4(hdib, x, y, p)                                        \
  80.           ((* DibPixelPtr4 (hdib, x, y) &= (0x0F << ((x) & 1 ? 4 : 0))),   \
  81.            (* DibPixelPtr4 (hdib, x, y) |= ((p)  << ((x) & 1 ? 0 : 4))))
  82.  
  83. #define DibSetPixel8(hdib, x, y, p)  (* DibPixelPtr8 (hdib, x, y) = p)
  84. #define DibSetPixel16(hdib, x, y, p) (* DibPixelPtr16 (hdib, x, y) = p)
  85. #define DibSetPixel24(hdib, x, y, p) (* DibPixelPtr24 (hdib, x, y) = p)
  86. #define DibSetPixel32(hdib, x, y, p) (* DibPixelPtr32 (hdib, x, y) = p)
  87.