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.

84 lines
2.0 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: CBanding.cpp
  3. *
  4. \**************************************************************************/
  5. #include "CBanding.h"
  6. #include <limits.h>
  7. extern HWND g_hWndMain;
  8. CBanding::CBanding(BOOL bRegression)
  9. {
  10. strcpy(m_szName,"Banding");
  11. m_bRegression=bRegression;
  12. }
  13. CBanding::~CBanding()
  14. {
  15. }
  16. void CBanding::Draw(Graphics *g)
  17. {
  18. TestBanding(g);
  19. }
  20. VOID CBanding::TestBanding(Graphics *g)
  21. {
  22. Unit u;
  23. RectF rect;
  24. REAL width = 10;
  25. RectF copyRect;
  26. RECT crect;
  27. WCHAR filename[256];
  28. GraphicsPath *path;
  29. HINSTANCE hInst=GetModuleHandleA(NULL);
  30. Bitmap *bitmap = new Bitmap(hInst, L"MARBLE_BMP");
  31. bitmap->GetBounds(&copyRect, &u);
  32. GetClientRect(g_hWndMain, &crect);
  33. rect.X = (30.0f/450.0f*crect.right);
  34. rect.Y = (30.0f/450.0f*crect.bottom);
  35. rect.Width = (crect.right-(70.0f/450.0f*crect.right));
  36. rect.Height = (crect.bottom-(70.0f/450.0f*crect.bottom));
  37. path = new GraphicsPath(FillModeAlternate);
  38. path->AddRectangle(rect);
  39. // Our ICM profile is hacked to flip the red and blue color channels
  40. // Apply a recolor matrix to flip them back so that if something breaks
  41. // ICM, the picture will look blue instead of the familiar colors.
  42. ImageAttributes *img = new ImageAttributes();
  43. img->SetWrapMode(WrapModeTile, Color(0xffff0000), FALSE);
  44. ColorMatrix flipRedBlue =
  45. {0, 0, 1, 0, 0,
  46. 0, 1, 0, 0, 0,
  47. 1, 0, 0, 0, 0,
  48. 0, 0, 0, 1, 0,
  49. 0, 0, 0, 0, 1};
  50. img->SetColorMatrix(&flipRedBlue);
  51. img->SetWrapMode(WrapModeTile, Color(0xffff0000), FALSE);
  52. TextureBrush textureBrush(bitmap, copyRect, img);
  53. g->FillPath(&textureBrush, path);
  54. Color blackColor(128, 0, 0, 0);
  55. SolidBrush blackBrush(blackColor);
  56. Pen blackPen(&blackBrush, width);
  57. g->DrawPath(&blackPen, path);
  58. delete img;
  59. delete path;
  60. delete bitmap;
  61. }