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.

70 lines
2.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: CSourceCopy.cpp
  3. *
  4. * This file contains the code to support the functionality test harness
  5. * for GDI+. This includes menu options and calling the appropriate
  6. * functions for execution.
  7. *
  8. * Created: 05-May-2000 - Jeff Vezina [t-jfvez]
  9. *
  10. * Copyright (c) 2000 Microsoft Corporation
  11. *
  12. \**************************************************************************/
  13. #include "CSourceCopy.h"
  14. CSourceCopy::CSourceCopy(BOOL bRegression)
  15. {
  16. strcpy(m_szName,"SourceCopy");
  17. m_bRegression=bRegression;
  18. }
  19. CSourceCopy::~CSourceCopy()
  20. {
  21. }
  22. void CSourceCopy::Draw(Graphics *g)
  23. {
  24. // This test demonstrates SetCompositingMode by drawing two overlapping
  25. // rectangles, using SourceCopy, into a temporary bitmap, then drawing
  26. // the bitmap (using SourceOver), onto the screen over a background.
  27. // Make a temporary surface
  28. Bitmap bmTemp((int)(300.0f/150.0f*TESTAREAWIDTH), (int)(300.0f/150.0f*TESTAREAHEIGHT), PixelFormat32bppPARGB);
  29. Graphics gTemp(&bmTemp);
  30. Graphics *gt=&gTemp;
  31. // First, draw a blue checkerboard pattern on the output Graphics
  32. SolidBrush blueBrush(Color::Blue);
  33. int i,j;
  34. for (i=0;i<3;i++)
  35. {
  36. for (j=0;j<3;j++)
  37. {
  38. if ((i+j) & 1)
  39. {
  40. g->FillRectangle(
  41. &blueBrush,
  42. (int)((100.0f+i*30.0f)/200.0f*TESTAREAWIDTH),
  43. (int)((100.0f+j*30.0f)/200.0f*TESTAREAHEIGHT),
  44. (int)(30.0f/200.0f*TESTAREAHEIGHT),
  45. (int)(30.0f/200.0f*TESTAREAHEIGHT));
  46. }
  47. }
  48. }
  49. gt->SetCompositingMode(CompositingModeSourceCopy);
  50. gt->SetSmoothingMode(g->GetSmoothingMode());
  51. // Clear the bitmap to the transparent color
  52. gt->Clear(Color(0,0,0,0));
  53. // Draw two overlapping rectangles to the temporary surface
  54. SolidBrush halfRedBrush(Color(128, 255, 0, 0));
  55. gt->FillRectangle(&halfRedBrush, (int)(28.0f/150.0f*TESTAREAWIDTH), (int)(84.0f/150.0f*TESTAREAHEIGHT), (int)(90.0f/150.0f*TESTAREAWIDTH), (int)(50.0f/150.0f*TESTAREAHEIGHT));
  56. SolidBrush halfGreenBrush(Color(128, 0, 255, 0));
  57. gt->FillRectangle(&halfGreenBrush, (int)(40.0f/150.0f*TESTAREAWIDTH), (int)(40.0f/150.0f*TESTAREAHEIGHT), (int)(100.0f/150.0f*TESTAREAWIDTH), (int)(60.0f/150.0f*TESTAREAHEIGHT));
  58. // SourceOver the result to the output Graphics
  59. g->DrawImage(&bmTemp, 0, 0, 0, 0, (int)TESTAREAWIDTH, (int)TESTAREAHEIGHT, UnitPixel);
  60. }