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.

133 lines
3.2 KiB

  1. /*==============================================================================
  2. This module provides MMR rendering support for viewing faxes.
  3. 19-Jan-94 RajeevD Integrated into IFAX viewer.
  4. ==============================================================================*/
  5. #include <ifaxos.h>
  6. #include <viewrend.h>
  7. #include <dcxcodec.h>
  8. #include "viewrend.hpp"
  9. #ifdef DEBUG
  10. DBGPARAM dpCurSettings = {"VIEWREND"};
  11. #endif
  12. // file signatures
  13. #define MMR_SIG 0x53465542 // "BUFS"
  14. #define RBA_SIG 0x53505741 // "AWPS"
  15. //==============================================================================
  16. // C Export Wrappers
  17. //==============================================================================
  18. #ifndef WIN32
  19. EXPORT_DLL BOOL WINAPI LibMain
  20. (HANDLE hInst, WORD wSeg, WORD wHeap, LPSTR lpszCmd)
  21. { return 1; }
  22. extern "C" {int WINAPI WEP (int nParam);}
  23. #pragma alloc_text(INIT_TEXT,WEP)
  24. int WINAPI WEP (int nParam)
  25. { return 1; }
  26. #endif
  27. //==============================================================================
  28. LPVOID
  29. WINAPI
  30. ViewerOpen
  31. (
  32. LPVOID lpFile, // IFAX key or Win3.1 path or OLE2 IStream
  33. DWORD nType, // data type: HRAW_DATA or LRAW_DATA
  34. LPWORD lpwResoln, // output pointer to x, y dpi array
  35. LPWORD lpwBandSize, // input/output pointer to output band size
  36. LPVIEWINFO lpViewInfo // output pointer to VIEWINFO struct
  37. )
  38. {
  39. GENFILE gf;
  40. DWORD dwSig;
  41. LPVIEWREND lpvr;
  42. VIEWINFO ViewInfo;
  43. DEBUGMSG (1, ("VIEWREND ViewerOpen entry\r\n"));
  44. // Read DWORD signature.
  45. if (!(gf.Open (lpFile, 0)))
  46. return_error (("VIEWREND could not open spool file!\r\n"));
  47. #ifdef VIEWDCX
  48. if (!gf.Read (&dwSig, sizeof(dwSig)))
  49. return_error (("VIEWREND could not read signature!\r\n"));
  50. #else
  51. dwSig = 0;
  52. #endif
  53. if (dwSig != DCX_SIG)
  54. {
  55. if (!gf.Seek (2, 0) || !gf.Read (&dwSig, sizeof(dwSig)))
  56. return_error (("VIEWREND could not read signature!\r\n"));
  57. }
  58. // Determine file type.
  59. switch (dwSig)
  60. {
  61. #ifdef VIEWMMR
  62. case MMR_SIG:
  63. lpvr = new MMRVIEW (nType);
  64. break;
  65. #endif
  66. #ifdef VIEWDCX
  67. case DCX_SIG:
  68. lpvr = new DCXVIEW (nType);
  69. break;
  70. #endif
  71. #ifdef VIEWRBA
  72. case RBA_SIG:
  73. case ID_BEGJOB:
  74. lpvr = new RBAVIEW (nType);
  75. break;
  76. #endif
  77. default:
  78. return_error (("VIEWREND could not recognize signature!\r\n"));
  79. }
  80. if (!lpViewInfo)
  81. lpViewInfo = &ViewInfo;
  82. // Initialize context.
  83. if (!lpvr->Init (lpFile, lpViewInfo, lpwBandSize))
  84. { delete lpvr; lpvr = NULL;}
  85. if (lpwResoln)
  86. {
  87. lpwResoln[0] = lpViewInfo->xRes;
  88. lpwResoln[1] = lpViewInfo->yRes;
  89. }
  90. return lpvr;
  91. }
  92. //==============================================================================
  93. BOOL WINAPI ViewerSetPage (LPVOID lpContext, UINT iPage)
  94. {
  95. return ((LPVIEWREND) lpContext)->SetPage (iPage);
  96. }
  97. //==============================================================================
  98. BOOL WINAPI ViewerGetBand (LPVOID lpContext, LPBITMAP lpbmBand)
  99. {
  100. return ((LPVIEWREND) lpContext)->GetBand (lpbmBand);
  101. }
  102. //==============================================================================
  103. BOOL WINAPI ViewerClose (LPVOID lpContext)
  104. {
  105. delete (LPVIEWREND) lpContext;
  106. return TRUE;
  107. }