Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
7.4 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: fastdib.h
  3. *
  4. * CreateCompatibleDIB definitions.
  5. *
  6. * Created: 02-Feb-1996 19:30:45
  7. * Author: Gilman Wong [gilmanw]
  8. *
  9. * Copyright (c) 1995 Microsoft Corporation
  10. *
  11. \**************************************************************************/
  12. /*
  13. This application draws a spinning RGB color cube into a bitmap and
  14. copies this bitmap to the display window, demonstrating the use
  15. of optimized DIBs with OpenGL. Note that pressing any of the number
  16. keys from 2-9 while the app is running will set a zoom factor which
  17. will cause the app to shrink the bitmap and to use StretchBlt to copy
  18. the bitmap to the display.
  19. The FastDIB API functions are implemented in fastdib.c. It is
  20. merely an interface layer to existing Win32 functions. It goal is
  21. to encapsulate some of the complexity of determing formats, initializing
  22. color tables, etc.
  23. Note that use of optimized DIBs on palettized (i.e., 8bpp) display devices
  24. on OpenGL/95 version 1.0 is broken. If running on Win95, the following
  25. line in timecube.c should be commented out:
  26. #define _COMPATIBLE_DIB_FIX_
  27. ------------------------------------------------------------------------------
  28. CreateCompatibleDIB
  29. -------------------
  30. HBITMAP APIENTRY CreateCompatibleDIB(hdc, hpal, ulWidth, ulHeight, ppvBits)
  31. HDC hdc;
  32. HPALETTE hpal;
  33. ULONG ulWidth;
  34. ULONG ulHeight;
  35. PVOID *ppvBits;
  36. Create a DIB section bitmap with an optimized format with respect to the
  37. specified display DC. Optimized in this case means that the bitmap format
  38. (and palette, if applicable) are matched to the display and will ensure
  39. the highest possible Blt performance.
  40. Parameters
  41. hdc
  42. Specifies display DC used to determine format. If hpal is NULL,
  43. this hdc is used to retrieve the system palette entries with which
  44. the DIB color table is initialized (on palettized display devices
  45. only).
  46. hpal
  47. Optional palette that, if specified, is used to initialize the DIB
  48. color table. If NULL, the system palette is used. Ignored for
  49. non-palettized display devices.
  50. ulWidth
  51. Specifies the width of the bitmap.
  52. ulHeight
  53. Specifies the height of the bitmap.
  54. ppvBits
  55. Returns a pointer to the DIB section bits with which the application
  56. can draw directly into the bitmap.
  57. Return Value
  58. The return value is the handle to the bitmap created. If the function
  59. fails, the return value is NULL.
  60. ------------------------------------------------------------------------------
  61. UpdateDIBColorTable
  62. -------------------
  63. BOOL APIENTRY UpdateDIBColorTable(hdcMem, hdc, hpal)
  64. HDC hdcMem;
  65. HDC hdc;
  66. HPALETTE hpal;
  67. Synchronize the color table of DIB bitmap selected into the specified
  68. memory DC with either the current system palette or the optionally
  69. specified logical palette.
  70. This function need only be invoked on palettized display devices.
  71. Parameters
  72. hdcMem
  73. Specified the memory DC into which the DIB of interest is selected.
  74. hdc
  75. Specifies the display DC for which the DIB is formatted. If hpal
  76. is NULL this hdc is used to retrieve the system palette entries
  77. with which the DIB color table is initialized (on palettized display
  78. devices only).
  79. hpal
  80. Optional palette that, if specified, is used to initialize the DIB
  81. color table. If NULL, the system palette is used. Ignored for
  82. non-palettized display devices.
  83. Return Value
  84. The return value is TRUE if the DIB color table is successfully updated.
  85. If the function fails, the return value is FALSE.
  86. Comments
  87. Typically, this function is called only if the logical palette in the
  88. display DC changes. For OpenGL apps, the logical palette is set only
  89. once for RGB modes, which implies that this function normally does not
  90. need to be used with RGB modes. Color index modes, however, may change
  91. the logical palette at any time. If that happens, then the application
  92. should invoke this function after the new palette has been realized.
  93. ------------------------------------------------------------------------------
  94. GetCompatibleDIBInfo
  95. --------------------
  96. BOOL APIENTRY GetCompatibleDIBInfo(hbm, ppvBase, plStride)
  97. HBITMAP hbm;
  98. PVOID *ppvBase;
  99. LONG *plStride;
  100. Returns information about the specified DIB section that allows the
  101. application to compute the address of a desired (x, y) pixel within
  102. the bitmap.
  103. Parameters
  104. hbm
  105. Specifies the DIB section bitmap of interest.
  106. ppvBase
  107. Returns a pointer to the origin of the bitmap. If the DIB
  108. is top-down, then this is the same as the ppvBits returned
  109. by the intial call to CreateCompatibleDIB. The default,
  110. however, is bottom-up.
  111. plStride
  112. Returns the stride or pitch of the bitmap (i.e., the difference
  113. in address between two vertically adjacent pixels). If the bitmap
  114. is top-down, this value is positive; if the bitmap is bottom-up,
  115. this value is negative.
  116. Return Value
  117. The return value is TRUE if the DIB color table is successfully updated.
  118. If the function fails, the return value is FALSE.
  119. Comments
  120. The ppvBase and plStride value returned will allow the application to
  121. compute the address any given pixel (x, y) in the bitmap as follows:
  122. PIXEL *ppix;
  123. ppix = (PIXEL *) (((BYTE *)*ppvBase) + (y * *plStride) + (x * sizeof(PIXEL)));
  124. ------------------------------------------------------------------------------
  125. GetDIBTranslationVector
  126. -----------------------
  127. BOOL APIENTRY GetDIBTranslationVector(HDC hdcMem, HPALETTE hpal, BYTE *pbVector)
  128. HDC hdcMem;
  129. HPALETTE hpal;
  130. BYTE *pbVector;
  131. Returns the translation vector that maps colors in the specified palette,
  132. hpal, to the DIB selected into the specified DC, hdcMem. This information
  133. is needed so that applications that draw directly into the DIB can translate
  134. the logical color indices into physical bitmap indices.
  135. This function should only be invoked on palettized display devices.
  136. Parameters
  137. hdcMem
  138. Specified the memory DC into which the DIB of interest is selected.
  139. hpal
  140. Specifies the logical palette which will be mapped to the DIB.
  141. pbVector
  142. Points to a buffer into which the translation vector will be copied.
  143. Return Value
  144. The return value is TRUE if the DIB color table is successfully updated.
  145. If the function fails, the return value is FALSE.
  146. Comments
  147. This function does not try to validate the buffer size. It is up to
  148. the application to allocate enough memory for the call. The amount of
  149. memory required in bytes equal in value to the number of entries
  150. in the logical palette:
  151. bufferSize = GetPaletteEntries(hpal, 0, 1, NULL) * sizeof(BYTE);
  152. */
  153. #ifndef SERVICES__FastDib_h__INCLUDED
  154. #define SERVICES__FastDib_h__INCLUDED
  155. HBITMAP APIENTRY CreateCompatibleDIB(HDC hdc, HPALETTE hpal, ULONG ulWidth, ULONG ulHeight, PVOID *ppvBits, BITMAPINFOHEADER * pbmih = NULL);
  156. BOOL APIENTRY UpdateDIBColorTable(HDC hdcMem, HDC hdc, HPALETTE hpal);
  157. BOOL APIENTRY GetCompatibleDIBInfo(HBITMAP hbm, PVOID *ppvBase, LONG *plStride);
  158. BOOL APIENTRY GetDIBTranslationVector(HDC hdcMem, HPALETTE hpal, BYTE *pbVector);
  159. #endif //SERVICES__FastDib_h__INCLUDED