本文整理汇总了C++中gdiplus::GraphicsPath类的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsPath类的具体用法?C++ GraphicsPath怎么用?C++ GraphicsPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GraphicsPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTxtSize
static Gdiplus::Size getTxtSize(std::wstring txt) {
Gdiplus::GraphicsPath path;
Gdiplus::FontFamily ff;
Gdiplus::Font* font = g_lv.f;
font->GetFamily(&ff);
Gdiplus::Rect rc;
Gdiplus::Size sz;
int len = txt.length();
if (len == 0) {
return sz;
}
bool is_space = false;
if (txt[len - 1] == L' ') {
txt[len - 1] = L'M';
is_space = true;
}
path.AddString(txt.c_str(),
len, &ff,
font->GetStyle(),
font->GetSize(),
Gdiplus::Point(1, 0),
NULL);
path.GetBounds(&rc);
int sd = (int)(font->GetSize() / 4);
sz.Width = rc.Width + sd;
if (is_space) {
sz.Width -= sd;
}
sz.Height = rc.Height;
return sz;
}
示例2: DrawTextOutline
BOOL GdiplusUtilities::DrawTextOutline(Gdiplus::Graphics& graphics,
LPCTSTR lpchText, int cchText, const Gdiplus::Rect& rc, const Gdiplus::StringFormat& format,
const Gdiplus::Font& font, Gdiplus::Color fill, Gdiplus::Color outline, INT outlineWidth,
BOOL bCalcOnly/* = FALSE*/, Gdiplus::Rect* rcCalc/* = NULL*/)
{
Gdiplus::FontFamily fontFamily;
font.GetFamily(&fontFamily);
Gdiplus::GraphicsPath path;
path.AddString(lpchText, cchText, &fontFamily, font.GetStyle(), font.GetHeight(&graphics), rc, &format);
if (rcCalc != NULL)
{
path.GetBounds(rcCalc);
rcCalc->Inflate(outlineWidth, outlineWidth);
}
if (bCalcOnly)
return TRUE;
Gdiplus::Pen pen(outline, (Gdiplus::REAL) outlineWidth);
if (graphics.DrawPath(&pen, &path) == Gdiplus::Ok)
{
Gdiplus::SolidBrush brush(fill);
return graphics.FillPath(&brush, &path) == Gdiplus::Ok;
}
return FALSE;
}
示例3: Draw
void SectionRenderer::Draw(Gdiplus::Graphics* g, MapViewport* viewport, const Component* component)
{
const Section* section = static_cast<const Section*>(component);
Vector2d last;
bool haslast = false;
const Properties& props = component->GetProperties();
Gdiplus::Pen pen(Gdiplus::Color(props.Get<prop::Color>(Gdiplus::Color::Black)),
props.Get<prop::LineWidth>(2));
pen.SetDashStyle((Gdiplus::DashStyle)props.Get<prop::DashStyle>(Gdiplus::DashStyle::DashStyleSolid));
pen.SetLineJoin(Gdiplus::LineJoin::LineJoinRound);
bool dispEnd = props.Get<prop::DisplaySectionEnd>(false);
Gdiplus::GraphicsPath path;
const Section::LocationList& locations = section->GetLocations();
for(const Location& location : locations)
{
Vector2d point = viewport->LocationToPixel(location);
if(haslast)
path.AddLine((float)last.GetX(), (float)last.GetY(), (float)point.GetX(), (float)point.GetY());
last = point;
haslast = true;
}
g->DrawPath(&pen, &path);
if(dispEnd)
{
Vector2d point = viewport->LocationToPixel(locations.front());
g->FillEllipse(pen.GetBrush(), point.GetX() - 3.f, point.GetY() - 3.f, 6.f, 6.f);
point.Set(viewport->LocationToPixel(locations.back()));
g->FillEllipse(pen.GetBrush(), point.GetX() - 3.f, point.GetY() - 3.f, 6.f, 6.f);
}
}
示例4: drawGraphicsPath
//-----------------------------------------------------------------------------
void GdiplusDrawContext::drawGraphicsPath (CGraphicsPath* _path, PathDrawMode mode, CGraphicsTransform* t)
{
GdiplusGraphicsPath* gdiPlusPath = dynamic_cast<GdiplusGraphicsPath*> (_path);
if (gdiPlusPath && pGraphics)
{
GdiplusDrawScope drawScope (pGraphics, currentState.clipRect, getCurrentTransform ());
Gdiplus::GraphicsPath* path = gdiPlusPath->getGraphicsPath ();
if (t)
{
Gdiplus::Matrix matrix;
convert (matrix, *t);
path = path->Clone ();
path->Transform (&matrix);
}
if (mode == kPathStroked)
{
pGraphics->DrawPath (getPen (), path);
}
else
{
path->SetFillMode (mode == kPathFilledEvenOdd ? Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding);
pGraphics->FillPath (getBrush (), path);
}
if (path != gdiPlusPath->getGraphicsPath ())
delete path;
}
}
示例5: DrawGradientFill
void CDisplayWindow::DrawGradientFill(HDC hdc,RECT *rc)
{
if(m_hBitmapBackground)
{
DeleteObject(m_hBitmapBackground);
}
/* Create the (temporary) off-screen buffer used for drawing. */
m_hBitmapBackground = CreateCompatibleBitmap(hdc,rc->right - rc->left,rc->bottom - rc->top);
SelectObject(m_hdcBackground,m_hBitmapBackground);
Gdiplus::Graphics graphics(m_hdcBackground);
Gdiplus::Rect DisplayRect(0,0,rc->right - rc->left,rc->bottom - rc->top);
Gdiplus::GraphicsPath Path;
Path.AddRectangle(DisplayRect);
Gdiplus::PathGradientBrush pgb(&Path);
pgb.SetCenterPoint(Gdiplus::Point(0,0));
pgb.SetCenterColor(m_CentreColor);
INT count = 1;
pgb.SetSurroundColors(&m_SurroundColor,&count);
graphics.FillRectangle(&pgb,DisplayRect);
/* This draws a separator line across the top edge of the window,
so that it is visually separated from other windows. */
Gdiplus::Pen NewPen(BORDER_COLOUR,1);
graphics.DrawLine(&NewPen,0,0,rc->right,0);
}
示例6: DrawImage
void CSkinUnitODL::DrawImage(Gdiplus::Graphics& gcDrawer, Gdiplus::RectF rtDrawArea, Gdiplus::REAL fScale)
{
if (m_imgSkin)
{
Gdiplus::GraphicsPath gcPath;
gcPath.AddRectangle(rtDrawArea);
DrawImage(gcDrawer, gcPath, Gdiplus::PointF(rtDrawArea.X,rtDrawArea.Y), fScale);
}
}
示例7: AddPolygon
void GraphicsPath::AddPolygon(const PointF* points, unsigned int pointCount) {
Gdiplus::GraphicsPath* gp = reinterpret_cast<Gdiplus::GraphicsPath*>(_private);
Gdiplus::PointF* gdiPoints = new Gdiplus::PointF[pointCount];
for(unsigned int a=0; a<pointCount; a++) {
gdiPoints[a] = Gdiplus::PointF(points[a]._x, points[a]._y);
}
gp->AddPolygon(gdiPoints, pointCount);
delete[] gdiPoints;
}
示例8: CreateOptions
/* Creating of the options from the script. */
bool DIALOGUE::CreateOptions(){
// atributes
std::wstring text;
Gdiplus::GraphicsPath path;
// caused changes which will be paired with the options
std::string state_name;
std::vector<state_changes> changes;
if(!script.FindElem(L"OPTIONS")){
TermLog("Options tag not found in the Dialogue scene, script.xml file is probably damaged.");
return false;
}
script.IntoElem();
// Going through the options
if(!script.FindElem(L"OPTION")){
script.OutOfElem();
TermLog("No option to choose found in the dialogue scene.");
return false;
}
else do {
text = script.GetAttrib(L"text");
line_top -= line_height; // Put the line above the previous
stat = path.AddString(text.c_str(), -1, fontFamily, Gdiplus::FontStyleBold, text_size, Gdiplus::PointF(0, Gdiplus::REAL(line_top)), &strformat);
if (stat != 0) StatusLog("GraphicPath.AddString()", stat, false);
script.IntoElem();
if(!CheckTests()){
script.OutOfElem();
continue;
}
// creates the map of state changes
while(script.FindElem(L"STATECHANGE")){
state_changes current_changes;
current_changes.name = wstring2string(script.GetData());
current_changes.value = atoi((wstring2string(script.GetAttrib(L"value"))).c_str());
current_changes.replace = atoi((wstring2string(script.GetAttrib(L"replace"))).c_str()) != 0 ? true : false;
changes.push_back(current_changes);
}
script.OutOfElem(); // Jumps out of the object
options.push_back(OPTION(text, &path, changes));
changes.clear();
StatusLog("GraphicPath.Reset()", path.Reset(), false);
} while(script.FindElem(L"OPTION"));
script.OutOfElem();
return true;
}
示例9: sb
void AirSpeed_Indicator::PT::DrawPointer(const PREADING pRading, Gdiplus::Graphics *pg)
{
Gdiplus::GraphicsPath path;
path.AddPath(&m_PT, FALSE);
Gdiplus::Matrix m;
float a = GetAngle(pRading);
m.RotateAt(a, Gdiplus::PointF(m_ptRotatePoint.X, m_ptRotatePoint.Y));
path.Transform(&m);
Gdiplus::SolidBrush sb(Gdiplus::Color::White);
pg->FillPath(&sb, &path);
}
示例10: DrawConnection
void CXTPFlowGraphPaintManager::DrawConnection(CXTPFlowGraphDrawContext* pDC, CXTPFlowGraphConnection* pConnection)
{
CRect rcConnectionBounds = pConnection->GetBoundingRect();
CRect rcBounds = pDC->GetClipRect();
CXTPFlowGraphControl* pControl = pConnection->GetControl();
if (rcBounds.right < rcConnectionBounds.left || rcBounds.left > rcConnectionBounds.right ||
rcBounds.top > rcConnectionBounds.bottom || rcBounds.bottom < rcConnectionBounds.top)
return;
if (pControl->GetZoomLevel() < m_dMinZoomLevelConnections)
return;
COLORREF clrConnection = pConnection->GetColor() != (COLORREF)-1 ? pConnection->GetColor() : m_clrConnection;
if (pConnection->IsSelected())
clrConnection = m_clrSelection;
pDC->SetPen(clrConnection, 2);
pDC->DrawCurve(pConnection->m_pPath);
if (pConnection->IsSelected() && pConnection->GetControlPoint() != CPoint(-1, -1))
{
pDC->SetPen(0, 0);
pDC->SetBrush(clrConnection);
CPoint pt(pConnection->GetControlPoint());
pDC->Ellipse(CRect(pt.x - 3, pt.y - 3, pt.x + 3, pt.y + 3));
}
if (m_bDrawArrow)
{
Gdiplus::GraphicsPath* path = pConnection->m_pPath->Clone();
path->Flatten();
const REAL rArrow = 10.0;
PointF ptEnd = XTPGetPosition(path, REAL(-m_nEllipseSize / 2));
PointF ptFrom = XTPGetPosition(path, REAL(- (m_nEllipseSize / 2 + rArrow)));
Point ptArrow[3];
PointF ptDiff = ptFrom - ptEnd;
ptArrow[0] = Point((int)ptEnd.X, (int)ptEnd.Y);
ptArrow[1] = Point(int(ptFrom.X - ptDiff.Y * (4.0) / rArrow), int(ptFrom.Y + ptDiff.X * (4.0) / rArrow));
ptArrow[2] = Point(int(ptFrom.X + ptDiff.Y * (4.0) / rArrow), int(ptFrom.Y - ptDiff.X * (4.0) / rArrow));
pDC->SetBrush(clrConnection);
pDC->FillPolygon((POINT*)ptArrow, 3);
delete path;
}
}
示例11: GetFrame
PVideoFrame __stdcall AutoTraceFilter::GetFrame(int n, IScriptEnvironment* env) {
// Grab the child frame
PVideoFrame childFrame = child->GetFrame(n, env);
// Create the bitmap - AutoTrace always wants a 24-bpp bitmap for some dumb reason
at_bitmap_type *bitmap;
bitmap = at_bitmap_new(srcWidth, srcHeight, 3);
size_t bitmap_size = srcWidth * srcHeight * 3;
// Pull the bitmap data
// We can just blt lines
const BYTE* srcBitmap = childFrame->GetReadPtr();
int pitch = childFrame->GetPitch();
int rowSize = childFrame->GetRowSize();
for (int y = 0; y < srcHeight; y++) {
// Note that R and B are swapped in this. It doesn't really matter.
memcpy_s(bitmap->bitmap + ((srcHeight - y - 1) * rowSize), bitmap_size, srcBitmap + (y * pitch), rowSize);
}
// This does the actual tracing:
at_splines_type* splines = at_splines_new(bitmap, fitting_opts, exception_handler, NULL);
// Now create the new frame. First, blank out the old frame
graphics->Clear(*backgroundColor);
at_real tx = ((at_real)destWidth) / ((at_real)srcWidth);
at_real ty = ((at_real)destHeight) / ((at_real)srcHeight);
for (unsigned int i = 0; i < splines->length; i++) {
at_spline_list_type spline_list = splines->data[i];
Gdiplus::GraphicsPath path;
for (unsigned int j = 0; j < spline_list.length; j++) {
at_spline_type* spline = &(spline_list.data[j]);
if (spline->degree == AT_LINEARTYPE) {
path.AddLine((Gdiplus::REAL)(spline->v[0].x * tx), (Gdiplus::REAL)(spline->v[0].y * ty),
(Gdiplus::REAL)(spline->v[3].x * tx), (Gdiplus::REAL)(spline->v[3].y * ty));
} else {
path.AddBezier(
(Gdiplus::REAL)(spline->v[0].x * tx), (Gdiplus::REAL)(spline->v[0].y * ty),
(Gdiplus::REAL)(spline->v[1].x * tx), (Gdiplus::REAL)(spline->v[1].y * ty),
(Gdiplus::REAL)(spline->v[2].x * tx), (Gdiplus::REAL)(spline->v[2].y * ty),
(Gdiplus::REAL)(spline->v[3].x * tx), (Gdiplus::REAL)(spline->v[3].y * ty));
}
}
path.CloseFigure();
// Red and blue are swapped here, so swap them back.
Gdiplus::Color color(spline_list.color.b, spline_list.color.g, spline_list.color.r);
Gdiplus::SolidBrush brush(color);
graphics->FillPath(&brush, &path);
}
at_splines_free(splines);
at_bitmap_free(bitmap);
// Now we need to create our result frame
PVideoFrame outputFrame = env->NewVideoFrame(vi);
BYTE* outputData = outputFrame->GetWritePtr();
env->BitBlt(outputData, outputFrame->GetPitch(), renderedFrameData, renderedFramePitch, destWidth*4, destHeight);
return outputFrame;
}
示例12: fillLinearGradient
//-----------------------------------------------------------------------------
void GdiplusDrawContext::fillLinearGradient (CGraphicsPath* _path, const CGradient& gradient, const CPoint& startPoint, const CPoint& endPoint, bool evenOdd, CGraphicsTransform* t)
{
#if DEBUG
DebugPrint ("WARNING: GdiplusDrawContext::fillLinearGradient is not working as expected ! FIXME");
#endif
GdiplusGraphicsPath* gdiPlusPath = dynamic_cast<GdiplusGraphicsPath*> (_path);
if (gdiPlusPath && pGraphics)
{
GdiplusDrawScope drawScope (pGraphics, currentState.clipRect, getCurrentTransform ());
Gdiplus::GraphicsPath* path = gdiPlusPath->getGraphicsPath ();
if (t)
{
Gdiplus::Matrix matrix;
convert (matrix, *t);
path = path->Clone ();
path->Transform (&matrix);
}
Gdiplus::Color* colors = new Gdiplus::Color [gradient.getColorStops ().size ()];
Gdiplus::REAL* positions = new Gdiplus::REAL [gradient.getColorStops ().size ()];
uint32_t index = 0;
for (CGradient::ColorStopMap::const_iterator it = gradient.getColorStops ().begin (); it != gradient.getColorStops ().end (); ++it, ++index)
{
CColor color = it->second;
color.alpha = (int8_t)((float)color.alpha * currentState.globalAlpha);
colors[index] = createGdiPlusColor (color);
positions[index] = (Gdiplus::REAL)it->first;
}
Gdiplus::PointF c1p ((Gdiplus::REAL)(startPoint.x), (Gdiplus::REAL)(startPoint.y));
Gdiplus::PointF c2p ((Gdiplus::REAL)(endPoint.x), (Gdiplus::REAL)(endPoint.y));
Gdiplus::LinearGradientBrush brush (c1p, c2p, colors[0], colors[gradient.getColorStops ().size () - 1]);
brush.SetInterpolationColors (colors, positions, static_cast<INT> (gradient.getColorStops ().size ()));
path->SetFillMode (evenOdd ? Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding);
pGraphics->FillPath (&brush, path);
if (path != gdiPlusPath->getGraphicsPath ())
delete path;
delete [] colors;
delete [] positions;
}
}
示例13: drawArc
//-----------------------------------------------------------------------------
void GdiplusDrawContext::drawArc (const CRect& rect, const float _startAngle, const float _endAngle, const CDrawStyle drawStyle)
{
if (pGraphics)
{
GdiplusDrawScope drawScope (pGraphics, currentState.clipRect, getCurrentTransform ());
float endAngle = _endAngle;
if (endAngle < _startAngle)
endAngle += 360.f;
endAngle = fabs (endAngle - _startAngle);
Gdiplus::RectF r ((Gdiplus::REAL)rect.left, (Gdiplus::REAL)rect.top, (Gdiplus::REAL)rect.getWidth (), (Gdiplus::REAL)rect.getHeight ());
Gdiplus::GraphicsPath path;
path.AddArc (r, _startAngle, endAngle);
if (drawStyle == kDrawFilled || drawStyle == kDrawFilledAndStroked)
pGraphics->FillPath (pBrush, &path);
if (drawStyle == kDrawStroked || drawStyle == kDrawFilledAndStroked)
pGraphics->DrawPath (pPen, &path);
}
}
示例14: FPressed
/*Fix current cursor point.*/
HRESULT INTERACTIVE::FPressed() {
if(temp_points_count <= 2) {
DisplayText(L"No polygon exists");
return S_FALSE;
}
Gdiplus::GraphicsPath boundaries;
boundaries.AddPolygon(temp_points, temp_points_count);
std::wstring name(L"Object ");
name.append(boost::lexical_cast<std::wstring, std::size_t>(objects.size()));
std::vector<state_changes> changes;
state_changes change = {"No_change", 0, 0};
changes.push_back(change);
objects.push_back(SCENE_OBJECT(&boundaries, name, L"!caption!", "!sound_path!", "!caption_sound_path!", changes, false));
temp_points_count = 0;
name.append(L" saved.");
BMP_mix->Clear(key_color);
DrawOutlines();
DisplayText(name);
return S_OK;
}
示例15: DrawTextVector
void TextElement::DrawTextVector(RenderContext& ctx)
{
Gdiplus::RectF textrect;
if (!RectFFromStyle(GetStyle(), textrect) || !m_font || m_text.empty())
return;
ctx.pGraphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
Gdiplus::FontFamily family(L"Tahoma");
Gdiplus::StringFormat format;
format.SetFormatFlags(Gdiplus::StringFormatFlagsLineLimit);
format.SetTrimming(Gdiplus::StringTrimmingEllipsisCharacter);
Gdiplus::GraphicsPath path;
path.AddString(m_text.c_str(), -1, &family, Gdiplus::FontStyleBold, 12, textrect, &format);
Gdiplus::Pen pen(Gdiplus::Color(192, 0, 0, 0), 0.0);
Gdiplus::SolidBrush brush(Gdiplus::Color(255, 255, 255, 255));
ctx.pGraphics->FillPath(&brush, &path);
ctx.pGraphics->DrawPath(&pen, &path);
}