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.

170 lines
4.7 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: CImaging.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 "CImaging.h"
  14. CImaging::CImaging(BOOL bRegression)
  15. {
  16. strcpy(m_szName,"Image : Misc");
  17. m_bRegression=bRegression;
  18. }
  19. CImaging::~CImaging()
  20. {
  21. }
  22. BOOL CALLBACK CImaging::MyDrawImageAbort(VOID* data)
  23. {
  24. UINT *count = (UINT*) data;
  25. *count += 1;
  26. return FALSE;
  27. }
  28. void CImaging::Draw(Graphics *g)
  29. {
  30. Point points[4];
  31. REAL width = 4; // Pen width
  32. WCHAR filename[256];
  33. wcscpy(filename,L"..\\data\\4x5_trans_Q60_cropped_1k.jpg");
  34. // Open the image with the appropriate ICM mode.
  35. Bitmap *bitmap = new Bitmap(filename, TRUE);
  36. // Create a texture brush.
  37. Unit u;
  38. RectF copyRect;
  39. bitmap->GetBounds(&copyRect, &u);
  40. // Choose an interesting portion of the source image to display
  41. // in the texture brush.
  42. copyRect.X = copyRect.Width/2-1;
  43. copyRect.Width = copyRect.Width/4-1;
  44. copyRect.X += copyRect.Width;
  45. copyRect.Height = copyRect.Height/2-1;
  46. // Our ICM profile is hacked to flip the red and blue color channels
  47. // Apply a recolor matrix to flip them back so that if something breaks
  48. // ICM, the picture will look blue instead of the familiar colors.
  49. ImageAttributes *img = new ImageAttributes();
  50. img->SetWrapMode(WrapModeTile, Color(0xffff0000), FALSE);
  51. ColorMatrix flipRedBlue =
  52. {0, 0, 1, 0, 0,
  53. 0, 1, 0, 0, 0,
  54. 1, 0, 0, 0, 0,
  55. 0, 0, 0, 1, 0,
  56. 0, 0, 0, 0, 1};
  57. img->SetColorMatrix(&flipRedBlue);
  58. img->SetWrapMode(WrapModeTile, Color(0xffff0000), FALSE);
  59. // Create a texture brush.
  60. TextureBrush textureBrush(bitmap, copyRect, img);
  61. // Create a radial gradient pen.
  62. Color redColor(255, 0, 0);
  63. SolidBrush redBrush(redColor);
  64. Pen redPen(&redBrush, width);
  65. GraphicsPath *path;
  66. points[0].X = (int)((float)(100*3+300)/1024.0f*TESTAREAWIDTH);
  67. points[0].Y = (int)((float)(60*3-100)/768.0f*TESTAREAHEIGHT);
  68. points[1].X = (int)((float)(-50*3+300)/1024.0f*TESTAREAWIDTH);
  69. points[1].Y = (int)((float)(60*3-100)/768.0f*TESTAREAHEIGHT);
  70. points[2].X = (int)((float)(150*3+300)/1024.0f*TESTAREAWIDTH);
  71. points[2].Y = (int)((float)(250*3-100)/768.0f*TESTAREAHEIGHT);
  72. points[3].X = (int)((float)(200*3+300)/1024.0f*TESTAREAWIDTH);
  73. points[3].Y = (int)((float)(120*3-100)/768.0f*TESTAREAHEIGHT);
  74. path = new GraphicsPath(FillModeAlternate);
  75. path->AddBeziers(points, 4);
  76. g->FillPath(&textureBrush, path);
  77. g->DrawPath(&redPen, path);
  78. delete img;
  79. delete path;
  80. delete bitmap;
  81. // Draw the apple png
  82. PointF destPoints[3];
  83. destPoints[0].X = (float)300/1024.0f*TESTAREAWIDTH;
  84. destPoints[0].Y = (float)50/768.0f*TESTAREAHEIGHT;
  85. destPoints[1].X = (float)450/1024.0f*TESTAREAWIDTH;
  86. destPoints[1].Y = (float)50/768.0f*TESTAREAHEIGHT;
  87. destPoints[2].X = (float)240/1024.0f*TESTAREAWIDTH;
  88. destPoints[2].Y = (float)200/768.0f*TESTAREAHEIGHT;
  89. Matrix mat;
  90. mat.Translate(0, 100);
  91. mat.TransformPoints(&destPoints[0], 3);
  92. wcscpy(filename, L"../data/apple1.png");
  93. bitmap = new Bitmap(filename);
  94. g->DrawImage(bitmap, &destPoints[0], 3);
  95. delete bitmap;
  96. // Draw the dog png
  97. destPoints[0].X = (float)30/1024.0f*TESTAREAWIDTH;
  98. destPoints[0].Y = (float)200/768.0f*TESTAREAHEIGHT;
  99. destPoints[1].X = (float)200/1024.0f*TESTAREAWIDTH;
  100. destPoints[1].Y = (float)200/768.0f*TESTAREAHEIGHT;
  101. destPoints[2].X = (float)200/1024.0f*TESTAREAWIDTH;
  102. destPoints[2].Y = (float)420/768.0f*TESTAREAHEIGHT;
  103. wcscpy(filename, L"..\\data\\dog2.png");
  104. bitmap = new Bitmap(filename);
  105. g->DrawImage(bitmap, &destPoints[0], 3);
  106. delete bitmap;
  107. // Draw the Balmer jpeg
  108. wcscpy(filename, L"..\\data\\ballmer.jpg");
  109. bitmap = new Bitmap(filename);
  110. RectF destRect(
  111. TESTAREAWIDTH/2.0f,
  112. TESTAREAHEIGHT/2.0f,
  113. TESTAREAWIDTH/2.0f,
  114. TESTAREAHEIGHT/2.0f
  115. );
  116. RectF srcRect;
  117. srcRect.X = 100;
  118. srcRect.Y = 40;
  119. srcRect.Width = 200;
  120. srcRect.Height = 200;
  121. g->DrawImage(
  122. bitmap,
  123. destRect,
  124. srcRect.X,
  125. srcRect.Y,
  126. srcRect.Width,
  127. srcRect.Height,
  128. UnitPixel
  129. );
  130. delete bitmap;
  131. }