最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

windows - Strange behaviour of GDI+ pen and drawlinedrawlines - Stack Overflow

programmeradmin5浏览0评论

The following code gets weird results:

    Graphics g(hdc);

    Pen pen(Color(0, 0, 0), 50.0f);

    std::vector<PointF> line;
    line.push_back({ 200, 200 });
    line.push_back({ 200, 100 });
    line.push_back({ 200, 100 });
    line.push_back({ 300, 100 });

    g.DrawLines(&pen, line.data(),line.size());

    std::vector<PointF> line2;
    line2.push_back({ 400, 200 });
    line2.push_back({ 400, 100 });
    line2.push_back({ 400, 60 });
    line2.push_back({ 400, 100 });
    line2.push_back({ 500, 100 });

    g.DrawLines(&pen, line2.data(), line2.size());

    std::vector<PointF> line3;
    line3.push_back({ 600, 200 });
    line3.push_back({ 600, 100 });
    line3.push_back({ 600, 95 });
    line3.push_back({ 600, 100 });
    line3.push_back({ 700, 100 });

    g.DrawLines(&pen, line3.data(), line3.size());

    for (std::size_t i = 0; i < line3.size(); ++i) {
        line3[i].X += 200;
    }

    for (std::size_t i = 1; i < line3.size(); ++i)
    {
        g.DrawLine(&pen, line3[i - 1], line3[i]);
    }

Here is the image drawn:

Comments (by images' numbers):

  1. No issues, works as expected
  2. Adding one point with displacement more than half of pen size; works as expected
  3. Moving this point closer so the distance is less than half of pen size. The first issue is here. What is this white area and the diagonal? And where is the part on top as on image (2)?
  4. Drawing the same image as (3) with series of DrawLine instead of DrawLines. What is this white box at the left top corner and where is the part on top as on image (2)?

Is this a bug or I misinterpret somehow pen's brushes shapes and drawing modes?

(OS: Windows Version 10.0.19044.1889; SDK Version 10.0.26100.0)

发布评论

评论列表(0)

  1. 暂无评论