CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: A line

  1. #1
    Join Date
    Nov 2007
    Posts
    93

    A line

    Hi!

    I draw a line between 2 points in a view. If the line is vertical, or horizontal, i can see a line,
    but for some dx/dy relations of the line i see a series of lines like a ladder or stair, trying to represent the line. I know that this is that way, and that it´s because of the pixels representation, but i want know if there is an easy way of draw lines more kindly to the sight. That seems smothers than this kind of stairs.

    Thanks,
    PERE.

  2. #2
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: A line

    Quote Originally Posted by pererm View Post
    I draw a line between 2 points in a view. If the line is vertical, or horizontal, i can see a line,
    but for some dx/dy relations of the line i see a series of lines like a ladder or stair, trying to represent the line. I know that this is that way, and that it´s because of the pixels representation, but i want know if there is an easy way of draw lines more kindly to the sight. That seems smothers than this kind of stairs.
    The question is: HOW do you draw that line?
    Here is something to read: Antialiasing with Lines and Curves
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  3. #3
    Join Date
    Nov 2007
    Posts
    93

    Re: A line

    `Thanks a lot!
    Is exactly what i want to know.
    Thanks.
    But is possible to implement antialiasing using C++ code?
    In this article seems it´s impossible, Isn' t it.

    PERE.

  4. #4
    Join Date
    Aug 2008
    Posts
    902

    Re: A line

    You still never answered the question asked, which is how you are drawing these lines.

    The article Vladimir linked is about GDI+, but you never said anything about using GDI+ in your first post.

  5. #5
    Join Date
    Nov 2007
    Posts
    93

    Re: A line

    Ok!
    I`m drawing simply using a pDC->LineTo(x,y,colorref) in the OnDraw() function.
    I´m not using Gdi+. So these can be the problem. Is possible use Gdi+ in C++ code?

    Thanks!
    PERE

  6. #6
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: A line

    Hi,

    to accomplish antialiasing you have more choices:


    • GDI+ (like in the link given) can be used in c++ of course.
      see http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx . The article starts with "Windows GDI+ is a class-based API for C/C++ programmers."
    • You can use a third party library. There are lots of them, some for free, some commercial. Google will help you to find that one you need.
    • Antilaliasing can be done using "normal" Windows GDI programming too. It could be some kind of slow, but if you only need a couple of lines it could be ok too. But you've to "re-invent the wheel", which can be fun, but will be hard work anyway.

    regards
    PA

  7. #7
    Join Date
    Nov 2007
    Posts
    93

    Re: A line

    Thanks for all!!!

    PERE

  8. #8
    Join Date
    Apr 1999
    Posts
    27,449

    Re: A line

    Quote Originally Posted by pererm View Post
    Ok!
    I`m drawing simply using a pDC->LineTo(x,y,colorref) in the OnDraw() function.
    All of these GDI operations, line drawing, printing, etc. all depends on the device context that you're using. In other words, the "pDC" is the determining factor in all of these operations and how they perform.

    If the video card you have has anti-aliasing features, then their drivers will automatically draw those lines "nicely". If you have a cheap video card that doesn't support it, then you get the jagged lines.

    So unless you are trying to support bad video cards or drivers, it doesn't make sense to do anti-aliasing yourself. Let the video hardware handle it for you.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; June 21st, 2011 at 04:48 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured