本文整理汇总了C++中gdiplus::GraphicsPath::AddLine方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsPath::AddLine方法的具体用法?C++ GraphicsPath::AddLine怎么用?C++ GraphicsPath::AddLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath::AddLine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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;
}
示例3: FillRoundRectangle
void Graphics::FillRoundRectangle(Brush* brush, const RectF& rc, float d) {
Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
Gdiplus::Brush* gdiBrush = reinterpret_cast<Gdiplus::Brush*>(brush->_private);
Gdiplus::GraphicsPath gp;
Gdiplus::RectF r(rc.GetLeft()-1.0f, rc.GetTop()-1.0f, rc.GetWidth(), rc.GetHeight());
gp.AddArc(r.X, r.Y, d, d, 180.0f, 90.0f);
gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270.0f, 90.0f);
gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0.0f, 90.0f);
gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90.0f, 90.0f);
gp.AddLine(r.X, r.Y + r.Height - d, r.X, r.Y + d / 2.0f);
g->FillPath(gdiBrush, &gp);
}
示例4: DrawRoundRectangle
void Graphics::DrawRoundRectangle(Pen* pen, const RectF& rc, float d) {
Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(pen->_private);
Gdiplus::GraphicsPath gp;
Gdiplus::RectF r(rc.GetLeft()-1.0f, rc.GetTop()-1.0f, rc.GetWidth(), rc.GetHeight());
gp.AddArc(r.X, r.Y, d, d, 180.0f, 90.0f);
gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270.0f, 90.0f);
gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0.0f, 90.0f);
gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90.0f, 90.0f);
gp.AddLine(r.X, r.Y + r.Height - d, r.X, r.Y + d / 2.0f);
g->DrawPath(gdiPen, &gp);
}
示例5: GetRoundRectGraphicsPath
BOOL GdiplusUtilities::GetRoundRectGraphicsPath(Gdiplus::GraphicsPath& p,
int x, int y, int width, int height, int radius, RectangleCorners corners)
{
int xw = x + width;
int yh = y + height;
int xwr = xw - radius;
int yhr = yh - radius;
int xr = x + radius;
int yr = y + radius;
int r2 = radius * 2;
int xwr2 = xw - r2;
int yhr2 = yh - r2;
p.StartFigure();
//Top Left Corner
if ((TopLeft & corners) == TopLeft)
{
p.AddArc(x, y, r2, r2, 180, 90);
}
else
{
p.AddLine(x, yr, x, y);
p.AddLine(x, y, xr, y);
}
//Top Edge
p.AddLine(xr, y, xwr, y);
//Top Right Corner
if ((TopRight & corners)
== TopRight)
{
p.AddArc(xwr2, y, r2, r2, 270, 90);
}
else
{
p.AddLine(xwr, y, xw, y);
p.AddLine(xw, y, xw, yr);
}
//Right Edge
p.AddLine(xw, yr, xw, yhr);
//Bottom Right Corner
if ((BottomRight & corners)
== BottomRight)
{
p.AddArc(xwr2, yhr2, r2, r2, 0, 90);
}
else
{
p.AddLine(xw, yhr, xw, yh);
p.AddLine(xw, yh, xwr, yh);
}
//Bottom Edge
p.AddLine(xwr, yh, xr, yh);
//Bottom Left Corner
if ((BottomLeft & corners)
== BottomLeft)
{
p.AddArc(x, yhr2, r2, r2, 90, 90);
}
else
{
p.AddLine(xr, yh, x, yh);
p.AddLine(x, yh, x, yhr);
}
//Left Edge
p.AddLine(x, yhr, x, yr);
p.CloseFigure();
return TRUE;
}