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.

130 lines
3.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: CMetafile.cpp
  3. *
  4. * This file contains the code to support the functionality test harness
  5. * for GDI+.
  6. *
  7. * Created: 14-Sep-2000 - DCurtis
  8. *
  9. * Copyright (c) 2000 Microsoft Corporation
  10. *
  11. \**************************************************************************/
  12. #include "CMetafile.h"
  13. #include "CFuncTest.h"
  14. extern CFuncTest g_FuncTest;
  15. CMetafile::CMetafile(BOOL bRegression,MetafileType metafileType,BOOL recordFile)
  16. {
  17. m_bRegression = bRegression;
  18. switch (metafileType)
  19. {
  20. #if 0 // not yet implemented
  21. case MetafileTypeWmf: // Standard WMF
  22. sprintf(m_szName,"Metafile WMF");
  23. RecordType = EmfTypeEmfOnly;
  24. break;
  25. case MetafileTypeWmfPlaceable: // Placeable Metafile format
  26. sprintf(m_szName,"Metafile WMF Placeable");
  27. RecordType = EmfTypeEmfOnly;
  28. break;
  29. #endif
  30. case MetafileTypeEmf: // EMF (not EMF+)
  31. sprintf(m_szName,"Metafile EMF");
  32. RecordType = EmfTypeEmfOnly;
  33. break;
  34. case MetafileTypeEmfPlusOnly: // EMF+ without dual, down-level records
  35. sprintf(m_szName,"Metafile EMF+");
  36. RecordType = EmfTypeEmfPlusOnly;
  37. break;
  38. case MetafileTypeEmfPlusDual: // EMF+ with dual, down-level records
  39. default:
  40. sprintf(m_szName,"Metafile EMF+ Dual");
  41. RecordType = EmfTypeEmfPlusDual;
  42. break;
  43. }
  44. if (recordFile)
  45. {
  46. strcat(m_szName, "(File)");
  47. }
  48. RecordFile = recordFile;
  49. FinalType = metafileType;
  50. }
  51. CMetafile::~CMetafile()
  52. {
  53. delete GdipMetafile;
  54. }
  55. Graphics *
  56. CMetafile::PreDraw(int &nOffsetX,int &nOffsetY)
  57. {
  58. Graphics * g = NULL;
  59. HDC referenceHdc = ::GetDC(g_FuncTest.m_hWndMain);
  60. RectF frameRect;
  61. if (referenceHdc != NULL)
  62. {
  63. frameRect.X = frameRect.Y = 0;
  64. frameRect.Width = (int)TESTAREAWIDTH;
  65. frameRect.Height = (int)TESTAREAHEIGHT;
  66. if (RecordFile)
  67. {
  68. GdipMetafile = new Metafile(L"test.emf",
  69. referenceHdc,
  70. RecordType,
  71. NULL);
  72. }
  73. else
  74. {
  75. GdipMetafile = new Metafile(referenceHdc,
  76. frameRect,
  77. MetafileFrameUnitPixel,
  78. RecordType,
  79. NULL);
  80. }
  81. g = new Graphics(GdipMetafile);
  82. }
  83. // Since we are doing the test on another surface
  84. nOffsetX = 0;
  85. nOffsetY = 0;
  86. ReleaseDC(g_FuncTest.m_hWndMain, referenceHdc);
  87. return g;
  88. }
  89. void CMetafile::PostDraw(RECT rTestArea)
  90. {
  91. // play from the Metafile to screen so we see the results
  92. if (RecordFile)
  93. {
  94. delete GdipMetafile;
  95. // close file
  96. GdipMetafile = new Metafile(L"test.emf");
  97. // read from file
  98. }
  99. HDC hdcOrig = GetDC(g_FuncTest.m_hWndMain);
  100. {
  101. Graphics g(hdcOrig);
  102. RectF destRect((REAL)rTestArea.left, (REAL)rTestArea.top, TESTAREAWIDTH, TESTAREAHEIGHT);
  103. g.DrawImage(GdipMetafile, destRect, 0, 0, TESTAREAWIDTH, TESTAREAHEIGHT, UnitPixel);
  104. }
  105. ReleaseDC(g_FuncTest.m_hWndMain, hdcOrig);
  106. delete GdipMetafile;
  107. GdipMetafile = NULL;
  108. }