Public paste
Undefined
By: Guest | Date: Nov 22 2009 10:37 | Format: None | Expires: never | Size: 3.46 KB | Hits: 878

  1. DWORD pGdi;
  2.  
  3. void InitGdi()
  4. {
  5.         Gdiplus::GdiplusStartupInput gdiStartInput;
  6.         Gdiplus::GdiplusStartup(&pGdi, &gdiStartInput, NULL);
  7. }
  8.  
  9. void DeInitGdi()
  10. {
  11.         Gdiplus::GdiplusShutdown(pGdi);
  12. }
  13.  
  14. Gdiplus::Color GdiCreateColor(int a, int r, int g, int b)
  15. {
  16.         return Gdiplus::Color::Color(a, r, g, b);
  17. }
  18.  
  19. void GdiDrawLine(Gdiplus::Color color, int x1, int y1, int x2, int y2, float penwidth, HDC hdc)
  20. {
  21.         Gdiplus::Graphics gdiGraphic(hdc);
  22.         Gdiplus::Pen gdiPen(Gdiplus::Color(color), penwidth);
  23.         gdiGraphic.DrawLine(&gdiPen, x1, y1, x2, y2);
  24.         //gdiGraphic.ReleaseHDC(hdc);
  25. }
  26.  
  27. void GdiDrawRect(Gdiplus::Color color, int x, int y, int rectw, int recth, float penwidth, HDC hdc)
  28. {
  29.         Gdiplus::Graphics gdiGraphic(hdc);
  30.         Gdiplus::Pen gdiPen(Gdiplus::Color(color), penwidth);
  31.         gdiGraphic.DrawRectangle(&gdiPen, x, y, rectw, recth);
  32.         //gdiGraphic.ReleaseHDC(hdc);
  33. }
  34.  
  35. void GdiDrawEllipse(Gdiplus::Color color, int x, int y, int ellipsew, int ellipseh, float penwidth, HDC hdc)
  36. {
  37.         Gdiplus::Graphics gdiGraphic(hdc);
  38.         Gdiplus::Pen gdiPen(Gdiplus::Color(color), penwidth);
  39.         gdiGraphic.DrawEllipse(&gdiPen, x, y, ellipsew, ellipseh);
  40.         //gdiGraphic.ReleaseHDC(hdc);
  41. }
  42.  
  43. void GdiDrawImage(int x, int y, WCHAR filename, HDC hdc)
  44. {
  45.         Gdiplus::Graphics gdiGraphic(hdc);
  46.         Gdiplus::Image gdiImage(&filename);
  47.         gdiGraphic.DrawImage(&gdiImage, x, y);
  48.         //gdiGraphic.ReleaseHDC(hdc);
  49. }
  50.  
  51. void GdiDrawGradiantLine(Gdiplus::Color clr1, Gdiplus::Color clr2 , int x1, int y1, int x2, int y2, float penwidth, HDC hdc)
  52. {
  53.         Gdiplus::Graphics gdiGraphic(hdc);
  54.         Gdiplus::LinearGradientBrush gdiBrush(Gdiplus::Point(x1, y1), Gdiplus::Point(x2, y2), clr1, clr2);
  55.         Gdiplus::Pen gdiPen(&gdiBrush, penwidth);
  56.         gdiGraphic.DrawLine(&gdiPen, x1, y1, x2, y2);
  57.         //gdiGraphic.ReleaseHDC(hdc);
  58. }
  59.  
  60. void GdiDrawGradiantRect(Gdiplus::Color clr1, Gdiplus::Color clr2, float x, float y, float rectw, float recth, HDC hdc)
  61. {
  62.         Gdiplus::Graphics gdiGraphic(hdc);
  63.         Gdiplus::RectF gdiRect(x, y, rectw, recth);
  64.         Gdiplus::LinearGradientBrush gdiBrush(gdiRect, clr1, clr2, 1);
  65.         gdiGraphic.FillRectangle(&gdiBrush, gdiRect);
  66.         //gdiGraphic.ReleaseHDC(hdc);
  67. }
  68.  
  69. void GdiDrawGradiantEllipse(Gdiplus::Color clr1, Gdiplus::Color clr2, float x, float y, float ellipsew, float ellipseh, HDC hdc)
  70. {
  71.         Gdiplus::Graphics gdiGraphic(hdc);
  72.         Gdiplus::RectF gdiRect(x, y, ellipsew, ellipseh);
  73.         Gdiplus::LinearGradientBrush gdiBrush(gdiRect, clr1, clr2, 1);
  74.         gdiGraphic.FillEllipse(&gdiBrush, gdiRect);
  75.         //gdiGraphic.ReleaseHDC(hdc);
  76. }
  77.  
  78. void GdiDrawFilledRect(Gdiplus::Color color, float x, float y, float rectw, float recth, HDC hdc)
  79. {
  80.         Gdiplus::Graphics gdiGraphic(hdc);
  81.         Gdiplus::RectF gdiRect(x, y, rectw, recth);
  82.         Gdiplus::SolidBrush gdiBrush(color);
  83.         gdiGraphic.FillRectangle(&gdiBrush, gdiRect);
  84.         //gdiGraphic.ReleaseHDC(hdc);
  85. }
  86.  
  87. void GdiDrawFilledEllipse(Gdiplus::Color color, float x, float y, float ellipsew, float ellipseh, HDC hdc)
  88. {
  89.         Gdiplus::Graphics gdiGraphic(hdc);
  90.         Gdiplus::RectF gdiRect(x, y, ellipseh, ellipsew);
  91.         Gdiplus::SolidBrush gdiBrush(color);
  92.         gdiGraphic.FillEllipse(&gdiBrush, gdiRect);
  93.         //gdiGraphic.ReleaseHDC(hdc);
  94. }
  95.  
  96. void GdiDrawColoredText(Gdiplus::Color color, float x, float y, float fSize, WCHAR cFont, WCHAR cText, HDC hdc)
  97. {
  98.         Gdiplus::Graphics gdiGraphic(hdc);
  99.         Gdiplus::FontFamily gdiFFamily(&cFont);
  100.         Gdiplus::Font gdiFont(&gdiFFamily, fSize);
  101.         Gdiplus::SolidBrush gdiBrush(color);
  102.         gdiGraphic.DrawString(&cText, -1, &gdiFont, Gdiplus::PointF(x, y), &gdiBrush);
  103.         //gdiGraphic.ReleaseHDC(hdc);
  104. }