- DWORD pGdi;
- void InitGdi()
- {
- Gdiplus::GdiplusStartupInput gdiStartInput;
- Gdiplus::GdiplusStartup(&pGdi, &gdiStartInput, NULL);
- }
- void DeInitGdi()
- {
- Gdiplus::GdiplusShutdown(pGdi);
- }
- Gdiplus::Color GdiCreateColor(int a, int r, int g, int b)
- {
- return Gdiplus::Color::Color(a, r, g, b);
- }
- void GdiDrawLine(Gdiplus::Color color, int x1, int y1, int x2, int y2, float penwidth, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::Pen gdiPen(Gdiplus::Color(color), penwidth);
- gdiGraphic.DrawLine(&gdiPen, x1, y1, x2, y2);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawRect(Gdiplus::Color color, int x, int y, int rectw, int recth, float penwidth, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::Pen gdiPen(Gdiplus::Color(color), penwidth);
- gdiGraphic.DrawRectangle(&gdiPen, x, y, rectw, recth);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawEllipse(Gdiplus::Color color, int x, int y, int ellipsew, int ellipseh, float penwidth, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::Pen gdiPen(Gdiplus::Color(color), penwidth);
- gdiGraphic.DrawEllipse(&gdiPen, x, y, ellipsew, ellipseh);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawImage(int x, int y, WCHAR filename, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::Image gdiImage(&filename);
- gdiGraphic.DrawImage(&gdiImage, x, y);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawGradiantLine(Gdiplus::Color clr1, Gdiplus::Color clr2 , int x1, int y1, int x2, int y2, float penwidth, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::LinearGradientBrush gdiBrush(Gdiplus::Point(x1, y1), Gdiplus::Point(x2, y2), clr1, clr2);
- Gdiplus::Pen gdiPen(&gdiBrush, penwidth);
- gdiGraphic.DrawLine(&gdiPen, x1, y1, x2, y2);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawGradiantRect(Gdiplus::Color clr1, Gdiplus::Color clr2, float x, float y, float rectw, float recth, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::RectF gdiRect(x, y, rectw, recth);
- Gdiplus::LinearGradientBrush gdiBrush(gdiRect, clr1, clr2, 1);
- gdiGraphic.FillRectangle(&gdiBrush, gdiRect);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawGradiantEllipse(Gdiplus::Color clr1, Gdiplus::Color clr2, float x, float y, float ellipsew, float ellipseh, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::RectF gdiRect(x, y, ellipsew, ellipseh);
- Gdiplus::LinearGradientBrush gdiBrush(gdiRect, clr1, clr2, 1);
- gdiGraphic.FillEllipse(&gdiBrush, gdiRect);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawFilledRect(Gdiplus::Color color, float x, float y, float rectw, float recth, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::RectF gdiRect(x, y, rectw, recth);
- Gdiplus::SolidBrush gdiBrush(color);
- gdiGraphic.FillRectangle(&gdiBrush, gdiRect);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawFilledEllipse(Gdiplus::Color color, float x, float y, float ellipsew, float ellipseh, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::RectF gdiRect(x, y, ellipseh, ellipsew);
- Gdiplus::SolidBrush gdiBrush(color);
- gdiGraphic.FillEllipse(&gdiBrush, gdiRect);
- //gdiGraphic.ReleaseHDC(hdc);
- }
- void GdiDrawColoredText(Gdiplus::Color color, float x, float y, float fSize, WCHAR cFont, WCHAR cText, HDC hdc)
- {
- Gdiplus::Graphics gdiGraphic(hdc);
- Gdiplus::FontFamily gdiFFamily(&cFont);
- Gdiplus::Font gdiFont(&gdiFFamily, fSize);
- Gdiplus::SolidBrush gdiBrush(color);
- gdiGraphic.DrawString(&cText, -1, &gdiFont, Gdiplus::PointF(x, y), &gdiBrush);
- //gdiGraphic.ReleaseHDC(hdc);
- }
Undefined
By: Guest | Date: Nov 22 2009 10:37 | Format: None | Expires: never | Size: 3.46 KB | Hits: 909
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago