Source code of Windows XP (NT5)
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.

269 lines
17 KiB

  1. ;/*
  2. ;----------------------------------------------------------------------------
  3. ; DIBENG.INC
  4. ; Copyright (c) 1992 Microsoft Corporation
  5. ;
  6. ; Dib Engine Interface Definitions
  7. ;----------------------------------------------------------------------------
  8. ;----------------------------------------------------------------------------
  9. ; General Comments:
  10. ; The DIB Engine is non-palettized from GDI's perspective. When an app
  11. ; selects a DIB into a memory DC, GDI will create a DIB Engine PDevice
  12. ; (see definition below) and will stuff in a 'DI' in the deType field.
  13. ; Subsequent operations on this DC will result in calls to the DIB Engine
  14. ; with this PDevice.
  15. ; Device drivers can also use the DIB Engine to handle most, if not all,
  16. ; of their rendering work. A device driver exports the DIB Engine PDevice
  17. ; as it's own PDevice to GDI. This PDevice contains a pointer to a
  18. ; BitmapInfo header in the driver's data segment. Immediately following
  19. ; this is an optional color table for devices less than 16 bpp.
  20. ;----------------------------------------------------------------------------
  21. ;----------------------------------------------------------------------------
  22. ; E Q U A T E S
  23. ;----------------------------------------------------------------------------
  24. BRUSHSIZE equ 8 ;height and width in pixels.
  25. VER_DIBENG equ 400h ;version = 4.0
  26. comment ~
  27. */
  28. #define BRUSHSIZE 8
  29. #define VER_DIBENG 0x400
  30. /*
  31. end comment ~
  32. ;----------------------------------------------------------------------------
  33. ; S T R U C T U R E S
  34. ;----------------------------------------------------------------------------
  35. ;----------------------------------------------------------------------------
  36. ; PDevice Structure for the DIB Engine. deType will contain 'DI' when GDI
  37. ; calls the DIB Engine to perform graphics operations on the dib. deType
  38. ; will contain a 0 or a Selector if a mini-driver is calling the DIB Engine
  39. ; to do graphics operations.
  40. ;----------------------------------------------------------------------------
  41. DIBENGINE struc ;*/ typedef struct { /*
  42. deType dw ? ; contains 'DI', 0 or ScreenSelector ;*/ WORD deType; /*
  43. deWidth dw ? ; Width of dib in pixels ;*/ WORD deWidth; /*
  44. deHeight dw ? ; Height of dib in pixels ;*/ WORD deHeight; /*
  45. deWidthBytes dw ? ; #bytes per scan line ;*/ WORD deWidthBytes; /*
  46. dePlanes db ? ; # of planes in bitmap ;*/ BYTE dePlanes; /*
  47. deBitsPixel db ? ; # of bits per pixel ;*/ BYTE deBitsPixel; /*
  48. deReserved1 dd ? ; cannot be used. ;*/ DWORD deReserved1; /*
  49. deDeltaScan dd ? ; + or -. Displacement to next scan. ;*/ DWORD deDeltaScan; /*
  50. delpPDevice dd ? ; Pointer to associated PDevice ;*/ LPBYTE delpPDevice; /*
  51. deBits df ? ; fword offset to bits of dib ;*/ DWORD deBitsOffset; /*
  52. ; ;*/ WORD deBitsSelector; /*
  53. deFlags dw ? ; additional flags ;*/ WORD deFlags; /*
  54. deVersion dw ? ; lsb=minor, msb=major (0400h = 4.0) ;*/ WORD deVersion; /*
  55. deBitmapInfo dd ? ; pointer to the bitmapinfo header ;*/ LPBITMAPINFO deBitmapInfo; /*
  56. deCursorExclude dd ? ; Cursor Exclude call back ;*/ void (FAR *deCursorExclude)(); /*
  57. deCursorUnexclude dd ? ; Cursor Unexclude call back ;*/ void (FAR *deCursorUnexclude)();/*
  58. deReserved2 dd ? ; Reserved. ;*/ DWORD deReserved2; /*
  59. DIBENGINE ends ;*/ } DIBENGINE, FAR *LPDIBENGINE; /*
  60. ;----------------------------------------------------------------------------
  61. ; Definitions for DIBEngine.deFlags
  62. ;----------------------------------------------------------------------------
  63. MINIDRIVER equ 0000000000000001b
  64. PALETTIZED equ 0000000000000010b
  65. SELECTEDDIB equ 0000000000000100b
  66. CURSOREXCLUDE equ 0000000000001000b
  67. DISABLED equ 0000000000010000b
  68. VRAM equ 1000000000000000b
  69. BANKEDVRAM equ 0100000000000000b
  70. BANKEDSCAN equ 0010000000000000b
  71. comment ~
  72. */
  73. #define MINIDRIVER 0x0001
  74. #define PALETTIZED 0x0002
  75. #define SELECTEDDIB 0x0004
  76. #define CURSOREXCLUDE 0x0008
  77. #define DISABLED 0x0010
  78. #define VRAM 0x8000
  79. #define BANKEDVRAM 0x4000
  80. #define BANKEDSCAN 0x2000
  81. /*
  82. end comment ~
  83. ;----------------------------------------------------------------------------
  84. ; Definitions for most significant byte of a physical color.
  85. ;----------------------------------------------------------------------------
  86. MONO_BIT equ 00000001b ;0=Black, 1=White
  87. PHYS_BIT equ 10000000b ;1=physical color, 0=logical color
  88. GREY_BIT equ 01000000b ;color is grey (r=g=b)
  89. comment ~
  90. */
  91. #define MONO_BIT 0x01
  92. #define PHYS_BIT 0x80
  93. #define GREY_BIT 0x40
  94. /*
  95. end comment ~
  96. ;----------------------------------------------------------------------------
  97. ; DIB Engine Color Table entry structure. This structure is used by device
  98. ; drivers that are using DIB Engine services for rendering. This structure
  99. ; is identical to the RGBQuad structure except for some bit definitions
  100. ; in the 4th byte.
  101. ;----------------------------------------------------------------------------
  102. DIBColorEntry struc ;*/ typedef struct { /*
  103. dceBlue db ? ;*/ BYTE dceBlue; /*
  104. dceGreen db ? ;*/ BYTE dceGreen; /*
  105. dceRed db ? ;*/ BYTE dceRed; /*
  106. dceFlags db ? ;*/ BYTE dceFlags; /*
  107. DIBColorEntry ends ;*/ } DIBColorEntry; /*
  108. ;----------------------------------------------------------------------------
  109. ; Definitions for DIBColorEntry.dceFlags
  110. ;----------------------------------------------------------------------------
  111. NONSTATIC equ 10000000b ;Inhibits color matching to this entry.
  112. MAPTOWHITE equ 00000001b ;0=Black, 1=White
  113. comment ~
  114. */
  115. #define NONSTATIC 0x80
  116. #define MAPTOWHITE 0x01
  117. /*
  118. end comment ~
  119. ;----------------------------------------------------------------------------
  120. ;----------------------------------------------------------------------------
  121. ; DIB Engine Physical Object Definitions
  122. ;----------------------------------------------------------------------------
  123. DIB_Pen struc ;*/ typedef struct { /*
  124. dpPenStyle dw ? ;*/ WORD dpPenStyle; /*
  125. dpPenFlags db ? ;currently none undefined. ;*/ BYTE dpPenFlags; /*
  126. dpPenBpp db ? ;*/ BYTE dpPenBpp; /*
  127. dpPenMono dd ? ;*/ DWORD dpPenMono; /*
  128. dpPenColor dd ? ;*/ DWORD dpPenColor; /*
  129. DIB_Pen ends ;*/ } DIB_Pen; /*
  130. DIB_Brush1 struc ;*/ typedef struct { /*
  131. dp1BrushFlags db ? ;Accelerator for solids ;*/ BYTE dp1BrushFlags; /*
  132. dp1BrushBpp db ? ;Brush Bits per pixel format ;*/ BYTE dp1BrushBpp; /*
  133. dp1BrushStyle dw ? ;Style of the brush ;*/ WORD dp1BrushStyle; /*
  134. dp1FgColor dd ? ;Logical fg color ;*/ DWORD dp1FgColor; /*
  135. dp1Hatch dw ? ;Hatching style ;*/ WORD dp1Hatch; /*
  136. dp1BgColor dd ? ;Logical bg color ;*/ DWORD dp1BgColor; /*
  137. dp1BrushMono db BRUSHSIZE*4 dup (?) ;Mono portion ;*/ BYTE dp1BrushMono [BRUSHSIZE*4];/*
  138. dp1BrushMask db BRUSHSIZE*4 dup (?) ;transparency mask (hatch pattern);*/ BYTE dp1BrushMask [BRUSHSIZE*4];/*
  139. dp1BrushBits db BRUSHSIZE*4 dup (?) ;8 rows, 8 columns of 1 bit/pixel ;*/ BYTE dp1BrushBits [BRUSHSIZE*4];/*
  140. DIB_Brush1 ends ;*/ } DIB_Brush1; /*
  141. DIB_Brush4 struc ;*/ typedef struct { /*
  142. dp4BrushFlags db ? ;Accelerator for solids ;*/ BYTE dp4BrushFlags; /*
  143. dp4BrushBpp db ? ;Brush Bits per pixel format ;*/ BYTE dp4BrushBpp; /*
  144. dp4BrushStyle dw ? ;Style of the brush ;*/ WORD dp4BrushStyle; /*
  145. dp4FgColor dd ? ;Logical fg color ;*/ DWORD dp4FgColor; /*
  146. dp4Hatch dw ? ;Hatching style ;*/ WORD dp4Hatch; /*
  147. dp4BgColor dd ? ;Logical bg color ;*/ DWORD dp4BgColor; /*
  148. dp4BrushMono db BRUSHSIZE*4 dup (?) ;Mono portion ;*/ BYTE dp4BrushMono [BRUSHSIZE*4];/*
  149. dp4BrushMask db BRUSHSIZE*4 dup (?) ;transparency mask (hatch pattern);*/ BYTE dp4BrushMask [BRUSHSIZE*4];/*
  150. dp4BrushBits db BRUSHSIZE*4 dup (?) ;8 rows, 8 columns of 4 bit/pixel ;*/ BYTE dp4BrushBits [BRUSHSIZE*4];/*
  151. DIB_Brush4 ends ;*/ } DIB_Brush4; /*
  152. DIB_Brush8 struc ;*/ typedef struct { /*
  153. dp8BrushFlags db ? ;Accelerator for solids ;*/ BYTE dp8BrushFlags; /*
  154. dp8BrushBpp db ? ;Brush Bits per pixel format ;*/ BYTE dp8BrushBpp; /*
  155. dp8BrushStyle dw ? ;Style of the brush ;*/ WORD dp8BrushStyle; /*
  156. dp8FgColor dd ? ;Logical fg color ;*/ DWORD dp8FgColor; /*
  157. dp8Hatch dw ? ;Hatching style ;*/ WORD dp8Hatch; /*
  158. dp8BgColor dd ? ;Logical bg color ;*/ DWORD dp8BgColor; /*
  159. dp8BrushMono db BRUSHSIZE*4 dup (?) ;Mono portion ;*/ BYTE dp8BrushMono [BRUSHSIZE*4];/*
  160. dp8BrushMask db BRUSHSIZE*4 dup (?) ;transparency mask (hatch pattern);*/ BYTE dp8BrushMask [BRUSHSIZE*4];/*
  161. dp8BrushBits db BRUSHSIZE*8 dup (?) ;8 rows,8 columns of 8 bit/pixel ;*/ BYTE dp8BrushBits [BRUSHSIZE*8];/*
  162. DIB_Brush8 ends ;*/ } DIB_Brush8; /*
  163. DIB_Brush16 struc ;*/ typedef struct { /*
  164. dp16BrushFlags db ? ;Accelerator for solids ;*/ BYTE dp16BrushFlags; /*
  165. dp16BrushBpp db ? ;Brush Bits per pixel format ;*/ BYTE dp16BrushBpp; /*
  166. dp16BrushStyle dw ? ;Style of the brush ;*/ WORD dp16BrushStyle; /*
  167. dp16FgColor dd ? ;Logical fg color ;*/ DWORD dp16FgColor; /*
  168. dp16Hatch dw ? ;Hatching style ;*/ WORD dp16Hatch; /*
  169. dp16BgColor dd ? ;Logical bg color ;*/ DWORD dp16BgColor; /*
  170. dp16BrushMono db BRUSHSIZE*4 dup (?) ;Mono portion ;*/ BYTE dp16BrushMono [BRUSHSIZE*4];/*
  171. dp16BrushMask db BRUSHSIZE*4 dup (?) ;transparency mask (hatch pattern);*/ BYTE dp16BrushMask [BRUSHSIZE*4];/*
  172. dp16BrushBits db BRUSHSIZE*16 dup (?);8 rows,8 columns of 16 bit/pixel;*/ BYTE dp16BrushBits [BRUSHSIZE*16];/*
  173. DIB_Brush16 ends ;*/ } DIB_Brush16; /*
  174. DIB_Brush24 struc ;*/ typedef struct { /*
  175. dp24BrushFlags db ? ;Accelerator for solids ;*/ BYTE dp24BrushFlags; /*
  176. dp24BrushBpp db ? ;Brush Bits per pixel format ;*/ BYTE dp24BrushBpp; /*
  177. dp24BrushStyle dw ? ;Style of the brush ;*/ WORD dp24BrushStyle; /*
  178. dp24FgColor dd ? ;Logical fg color ;*/ DWORD dp24FgColor; /*
  179. dp24Hatch dw ? ;Hatching style ;*/ WORD dp24Hatch; /*
  180. dp24BgColor dd ? ;Logical bg color ;*/ DWORD dp24BgColor; /*
  181. dp24BrushMono db BRUSHSIZE*4 dup (?) ;Mono portion ;*/ BYTE dp24BrushMono [BRUSHSIZE*4];/*
  182. dp24BrushMask db BRUSHSIZE*4 dup (?) ;transparency mask (hatch pattern);*/ BYTE dp24BrushMask [BRUSHSIZE*4];/*
  183. dp24BrushBits db BRUSHSIZE*24 dup (?);8 rows,8 columns of 24 bit/pixel ;*/ BYTE dp24BrushBits [BRUSHSIZE*24];/*
  184. DIB_Brush24 ends ;*/ } DIB_Brush24; /*
  185. DIB_Brush32 struc ;*/ typedef struct { /*
  186. dp32BrushFlags db ? ;Accelerator for solids ;*/ BYTE dp32BrushFlags; /*
  187. dp32BrushBpp db ? ;Brush Bits per pixel format ;*/ BYTE dp32BrushBpp; /*
  188. dp32BrushStyle dw ? ;Style of the brush ;*/ WORD dp32BrushStyle; /*
  189. dp32FgColor dd ? ;Logical fg color ;*/ DWORD dp32FgColor; /*
  190. dp32Hatch dw ? ;Hatching style ;*/ WORD dp32Hatch; /*
  191. dp32BgColor dd ? ;Logical bg color ;*/ DWORD dp32BgColor; /*
  192. dp32BrushMono db BRUSHSIZE*4 dup (?) ;Mono portion ;*/ BYTE dp32BrushMono [BRUSHSIZE*4];/*
  193. dp32BrushMask db BRUSHSIZE*4 dup (?) ;transparency mask (hatch pattern);*/ BYTE dp32BrushMask [BRUSHSIZE*4];/*
  194. dp32BrushBits db BRUSHSIZE*32 dup (?);8 rows,8 columns of 32 bit/pixel ;*/ BYTE dp32BrushBits [BRUSHSIZE*32];/*
  195. DIB_Brush32 ends ;*/ } DIB_Brush32; /*
  196. ;----------------------------------------------------------------------------
  197. ; Definitions for DIB_Brushxx.dpxxBrushFlags
  198. ;----------------------------------------------------------------------------
  199. COLORSOLID equ 00000001b ;Color part is solid.
  200. MONOSOLID equ 00000010b ;Mono part is solid.
  201. PATTERNMONO equ 00000100b ;Pattern brush came from a mono bitmap.
  202. MONOVALID equ 00001000b ;Mono part is valid.
  203. MASKVALID equ 00010000b ;Transparency Mask part is valid.
  204. comment ~
  205. */
  206. #define COLORSOLID 0x01
  207. #define MONOSOLID 0x02
  208. #define PATTERNMONO 0x04
  209. #define MONOVALID 0x08
  210. #define MASKVALID 0x10
  211. /*
  212. end comment ~
  213. ;----------------------------------------------------------------------------
  214. ; M A C R O S
  215. ;----------------------------------------------------------------------------
  216. ;----------------------------------------------------------------------------
  217. ; Cycle24 i
  218. ;
  219. ; This macro cycle a replicated 24 bit color in register eax, 'i' times.
  220. ; If 'i' is blank, the cycle is done one time, else it is done twice
  221. ;----------------------------------------------------------------------------
  222. Cycle24 macro i
  223. ifb <i> ;assume eax = 'brgb'
  224. mov al,ah ;eax = 'brgg'
  225. ror eax,8 ;eax = 'gbrg'
  226. else
  227. rol eax,16 ;eax = 'gbbr'
  228. mov ah,al ;eax = 'gbrr'
  229. ror eax,8 ;eax = 'rgbr'
  230. endif
  231. endm
  232. ;----------------------------------------------------------------------------
  233. ; ColorToMono
  234. ; Entry: red, green, blue
  235. ; Exit: blue = intensity.
  236. ;----------------------------------------------------------------------------
  237. ColorToMono macro red, green, blue
  238. add blue,red ;R+B
  239. rcr blue,1 ;(R+B)/2
  240. add blue,green ;pitch in Green
  241. rcr blue,1 ;G/2 + (R+B)/4
  242. endm ColorToMono
  243. ;----------------------------------------------------------------------------
  244. ; ColorToMonoBit
  245. ; Entry: red, green, blue
  246. ; Exit: blue = 0 if color maps to black
  247. ; blue = 1 if color maps to white
  248. ;----------------------------------------------------------------------------
  249. ColorToMonoBit macro red, green, blue
  250. ColorToMono red,green,blue ; Call ColorToMono to derive intensity.
  251. cmp blue,127
  252. setnc blue
  253. endm ColorToMonoBit
  254. ;*/