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.

240 lines
6.6 KiB

  1. //
  2. // fuimg2.c
  3. //
  4. // September.3,1997 H.Ishida (FPL)
  5. // fuxlers.dll (NT5.0 MiniDriver)
  6. //
  7. // Aug.2,1996 H.Ishida(FPL)
  8. // FJXL.DLL (NT4.0 MiniDriver)
  9. //
  10. // COPYRIGHT(C) FUJITSU LIMITED 1996-1997
  11. #include "fuxl.h"
  12. #include "fuimg2.h"
  13. //
  14. // Win-F RTGIMG2 output routine
  15. // RTGIMG2:
  16. // GS<\x1D> + P1<\x30> + Space<\x20> + a<\x61>
  17. // + Pc + Pxh + Pxl + Pyh + Pyl + Pyh + D1 + ... + D64
  18. // { + D1 + ... + D64 } + Pc
  19. //
  20. // P1 must be 30(hex)
  21. //
  22. // Pc: number of the following block.
  23. // if Pc is 0, terminate RTGIMG2.
  24. //
  25. // Pxl, Pxh, Pyl, Pyh: coordinate of the following block.
  26. // it must be a multiple of 32.
  27. //
  28. // X->
  29. // <-- 16dot -->
  30. // 1 8 9 16
  31. // +--------+--------+
  32. // | D1 | D2 |
  33. // +--------+--------+ ^
  34. // | | D3 | D4 | |
  35. // v +--------+--------+ |
  36. // Y . . . 16dot
  37. // . . . |
  38. // . . . |
  39. // +--------+--------+ v
  40. // | D63 | D64 |
  41. // +--------+--------+
  42. // White dot:0 Black dot:1
  43. //
  44. const UINT MAX_BLOCK = 255;
  45. const UINT CB_RTGIMG2HEADER = 5;
  46. const UINT CB_RTGIMG2BLOCK = 64;
  47. const UINT IDX_BLOCK_COUNTER = 0;
  48. //
  49. // LPBYTE fuxlRtgimg2OutputData(
  50. // PDEVOJB pdevobj // MINI5 data
  51. // LPBYTE lpbDst, // address of data to be output(spool).
  52. // UINT x, // x-coordinate
  53. // UINT y, // y-coordinate
  54. // UINT uTmp // 00h: entire block is white. otherwise block is not white.
  55. // );
  56. //
  57. // Output RTGIMG2 block to spool.
  58. //
  59. // Return value:
  60. // address of next block to be stored.
  61. //
  62. static LPBYTE fuxlRtgimg2OutputData(PDEVOBJ pdevobj, LPBYTE lpbDst, UINT x, UINT y, UINT uTmp)
  63. {
  64. if(uTmp == 0){
  65. // entire block is white.
  66. // igonre this block. flush blocks in buffer.
  67. if(lpbDst[IDX_BLOCK_COUNTER] > 0){
  68. WRITESPOOLBUF(pdevobj,
  69. lpbDst,
  70. lpbDst[IDX_BLOCK_COUNTER] * CB_RTGIMG2BLOCK + CB_RTGIMG2HEADER);
  71. lpbDst[IDX_BLOCK_COUNTER] = 0;
  72. }
  73. }
  74. else {
  75. if(lpbDst[IDX_BLOCK_COUNTER] == 0){
  76. // first block, in buffer, needs its coordinate.
  77. lpbDst[1] = HIBYTE((WORD)x); // Pxh
  78. lpbDst[2] = LOBYTE((WORD)x); // Pxl
  79. lpbDst[3] = HIBYTE((WORD)y); // Pyh
  80. lpbDst[4] = LOBYTE((WORD)y); // Pyl
  81. }
  82. lpbDst[IDX_BLOCK_COUNTER]++;
  83. if(lpbDst[IDX_BLOCK_COUNTER] >= MAX_BLOCK){
  84. WRITESPOOLBUF(pdevobj,
  85. lpbDst,
  86. lpbDst[IDX_BLOCK_COUNTER] * CB_RTGIMG2BLOCK + CB_RTGIMG2HEADER);
  87. lpbDst[IDX_BLOCK_COUNTER] = 0;
  88. }
  89. }
  90. // return pointer for the address, next block will be stored.
  91. return lpbDst + lpbDst[IDX_BLOCK_COUNTER] * CB_RTGIMG2BLOCK + CB_RTGIMG2HEADER;
  92. }
  93. //
  94. // void FuxlOutputRTGIMG2(
  95. // PDEVOBJ pdevobj, // MINI5 data
  96. // LPCBYTE lpBuf, // address of image
  97. // UINT bxSrc, // width of image (in byte)
  98. // UINT y, // y-coordinate
  99. // UINT cy // height of image (scanline)
  100. // );
  101. //
  102. // Convert image to RTGIMG2 command sequence, and spool.
  103. //
  104. //
  105. // Souce image data:
  106. //
  107. // | <-------------------- bxSrc ----------------------> |
  108. // lpBuf ->*--------+--------+--------+--------+--------+--------+---
  109. // | | | | | | | ^
  110. // +--------+--------+--------+--------+--------+--------+ |
  111. // | | | | | | | cy
  112. // +--------+--------+--------+--------+--------+--------+ |
  113. // | | | | | | | |
  114. // +--------+--------+--------+--------+--------+--------+ |
  115. // | | | | | | | v
  116. // +--------+--------+--------+--------+--------+--------+---
  117. //
  118. // coordinate of '*' (left-top of image) is (0, y)
  119. // white dot:0
  120. // black dot:1
  121. //
  122. //
  123. void fuxlOutputRTGIMG2(PDEVOBJ pdevobj, LPCBYTE lpBuf, UINT bxSrc, UINT y, UINT cy)
  124. {
  125. LPCBYTE lpbSrc;
  126. LPBYTE lpbDst;
  127. LPCBYTE lpbTmpSrc;
  128. LPBYTE lpbTmpDst;
  129. UINT uTmp;
  130. UINT x;
  131. UINT i, j, ii;
  132. lpbDst = (LPBYTE)MemAllocZ(CB_RTGIMG2HEADER + MAX_BLOCK * CB_RTGIMG2BLOCK);
  133. if(lpbDst == NULL)
  134. return;
  135. WRITESPOOLBUF(pdevobj, "\x1D\x30\x20\x61", 4); // RTGIMG2 start
  136. lpbSrc = lpBuf;
  137. lpbDst[0] = 0; // Pc
  138. lpbDst[1] = 0; // Pxl
  139. lpbDst[2] = 0; // Pxh
  140. lpbDst[3] = 0; // Pyl
  141. lpbDst[4] = 0; // Pyh
  142. lpbTmpDst = &lpbDst[CB_RTGIMG2HEADER];
  143. for(i = cy; i >= 32; i -= 32){
  144. x = 0;
  145. for(j = bxSrc; j >= 2; j -= 2){
  146. lpbTmpSrc = lpbSrc;
  147. uTmp = 0;
  148. for(ii = 32; ii > 0; --ii){
  149. uTmp |= lpbTmpSrc[0];
  150. *lpbTmpDst++ = lpbTmpSrc[0];
  151. uTmp |= lpbTmpSrc[1];
  152. *lpbTmpDst++ = lpbTmpSrc[1];
  153. lpbTmpSrc += bxSrc;
  154. }
  155. lpbTmpDst = fuxlRtgimg2OutputData(pdevobj, lpbDst, x, y, uTmp);
  156. x += 16;
  157. lpbSrc += 2;
  158. }
  159. if(j > 0){
  160. // right edge of image
  161. // j must be 1.
  162. lpbTmpSrc = lpbSrc;
  163. uTmp = 0;
  164. for(ii = 32; ii > 0; --ii){
  165. uTmp |= lpbTmpSrc[0];
  166. *lpbTmpDst++ =lpbTmpSrc[0];
  167. *lpbTmpDst++ = 0; // padding for right side
  168. lpbTmpSrc += bxSrc;
  169. }
  170. lpbTmpDst = fuxlRtgimg2OutputData(pdevobj, lpbDst, x, y, uTmp);
  171. lpbSrc++;
  172. }
  173. // flush buffer
  174. lpbTmpDst = fuxlRtgimg2OutputData(pdevobj, lpbDst, x, y, 0);
  175. lpbSrc += bxSrc * 31;
  176. y += 32;
  177. }
  178. if(i > 0){
  179. // bottom edge of image
  180. x = 0;
  181. for(j = bxSrc; j >= 2; j -= 2){
  182. lpbTmpSrc = lpbSrc;
  183. uTmp = 0;
  184. for(ii = i; ii > 0; --ii){
  185. uTmp |= lpbTmpSrc[0];
  186. *lpbTmpDst++ = lpbTmpSrc[0];
  187. uTmp |= lpbTmpSrc[1];
  188. *lpbTmpDst++ = lpbTmpSrc[1];
  189. lpbTmpSrc += bxSrc;
  190. }
  191. for(ii = 32 - i; ii > 0; --ii){
  192. *lpbTmpDst++ = 0; // padding for bottom lines
  193. *lpbTmpDst++ = 0; // padding for bottom lines
  194. }
  195. lpbTmpDst = fuxlRtgimg2OutputData(pdevobj, lpbDst, x, y, uTmp);
  196. x += 16;
  197. lpbSrc += 2;
  198. }
  199. if(j > 0){
  200. // right-bottom corner of image
  201. // j must be 1.
  202. lpbTmpSrc = lpbSrc;
  203. uTmp = 0;
  204. for(ii = i; ii > 0; --ii){
  205. uTmp |= lpbTmpSrc[0];
  206. *lpbTmpDst++ = lpbTmpSrc[0];
  207. *lpbTmpDst++ = 0; // padding for right side
  208. lpbTmpSrc += bxSrc;
  209. }
  210. for(ii = 32 - i ; ii > 0; --ii){
  211. *lpbTmpDst++ = 0; // padding for bottom lines
  212. *lpbTmpDst++ = 0; // padding for bottom lines
  213. }
  214. lpbTmpDst = fuxlRtgimg2OutputData(pdevobj, lpbDst, x, y, uTmp);
  215. }
  216. // flush buffer
  217. lpbTmpDst = fuxlRtgimg2OutputData(pdevobj, lpbDst, x, y, 0);
  218. }
  219. WRITESPOOLBUF(pdevobj, "\x00", 1); // RTGIMG2 terminate
  220. MemFree(lpbDst);
  221. }
  222. // end of fuimg2.c