How can I draw a thinner line with wxPen?
How can I draw a thinner line with wxPen?
Hello,
I have a small problem. I need to draw some colored lines.
wxDc.SetPen(wxPen(wxColour(255,0,0),1, wxDOT))
And I found the line looks too thick.
While wxPen(const wxColour& colour, int width = 1, int style = wxSOLID), there is no way to set the width to be a float value or to make it smaller than 1.
How could I draw a thinner line? Thanks a lot.
Cris
I have a small problem. I need to draw some colored lines.
wxDc.SetPen(wxPen(wxColour(255,0,0),1, wxDOT))
And I found the line looks too thick.
While wxPen(const wxColour& colour, int width = 1, int style = wxSOLID), there is no way to set the width to be a float value or to make it smaller than 1.
How could I draw a thinner line? Thanks a lot.
Cris
How would you do that ? If you draw < 1 pixel straight horizontal or vertical it would not be drawn. If you need anti aliasing for e.g. circles then you need to have something like AntiGrain
http://www.antigrain.com/
It is truly worth considering if the overhead justifies the pixel thickness.
- Jorgen
http://www.antigrain.com/
It is truly worth considering if the overhead justifies the pixel thickness.
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Re
Hello, Jorg,
The reason I think the line drawn in wxWidgets looks too thick is that I draw the same line on Mac using Cocoa and the line looks much thinner.
So that I have to find the way to make the line thinner or looks similar like the line drawn in Cocoa.
Thanks.
Cris
The reason I think the line drawn in wxWidgets looks too thick is that I draw the same line on Mac using Cocoa and the line looks much thinner.
So that I have to find the way to make the line thinner or looks similar like the line drawn in Cocoa.
Thanks.
Cris
What I don't understand is if your physical pixel size is 1 (meaning 1:1 on the screen) how can your line be thinner, because the bitmap buffer from your videocard simply can't display pixels of .5 thickness. 1 is the smallest size. If it looks thinner, show two screenshots. My best guess is that you are seeing antialiasing, and that is not standard supported in wxWidgets. You will have to tap into the windows image API and / or use a library that does that for you.
- Jorgen
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
- sherazjaved
- Knows some wx things
- Posts: 44
- Joined: Thu Feb 02, 2006 5:06 am
- Location: Pakistan
- Contact:
DC.SetPen(wxPen( wxColor( CUtilities:: InverseColor(255),CUtilities:: InverseColor(255), CUtilities:: InverseColor(34) ),1,wxSOLID) );
you can change this hilighted value to change the Pen Width and after that draw a Line using DrawLine() method
you can change this hilighted value to change the Pen Width and after that draw a Line using DrawLine() method
Mac OS X Server 10.4.5, X-Code 2.4, Gcc 4.0
Solaris 8.0 9.0, Gcc
Windows XP SP2, VC6.0
------------------------------------
Sheraz
Solaris 8.0 9.0, Gcc
Windows XP SP2, VC6.0
------------------------------------
Sheraz
Re: How can I draw a thinner line with wxPen?
So many years have passed but the problem still exit. I'm using wxWidgets 3.1.5 on Windows 10 and I just tried to draw a black line by one pixel width. And I getting a line no less then 2 pixels width, and a line colour seems to be not so black but rather dark gray. Is it something wrong with me or wxWidgtes?
Re: How can I draw a thinner line with wxPen?
Can you show a screenshot and some code?valery_s wrote: ↑Fri Jun 04, 2021 11:17 am So many years have passed but the problem still exit. I'm using wxWidgets 3.1.5 on Windows 10 and I just tried to draw a black line by one pixel width. And I getting a line no less then 2 pixels width, and a line colour seems to be not so black but rather dark gray. Is it something wrong with me or wxWidgtes?
I suspect that you're working on a high dpi screen with font scaling >100% and that your application is not DPI aware.
Use the source, Luke!
Re: How can I draw a thinner line with wxPen?
Yes, my screen resolution is 2560 x 1440. But how can I make my application be DPI aware ? I'm novice in wxWidgets.
Re: How can I draw a thinner line with wxPen?
The resolution itself is not important, it's about the scaling value set in Windows 10 settings.
In principle dpi-awareness is set through an application manifest. How to integrate that depends on your compiler/IDE.
If you build any of the wxWidgets samples with the provides makefiles / solution files, the resulting executable should be dpi-aware. Please try that with the "drawing" sample and check how it looks.
A non-dpiaware app will be scaled up by Windows and everything looks a bit "blurry".
Use the source, Luke!
Re: How can I draw a thinner line with wxPen?
I'm using VS2019 Community and a classic C++ project. Never before faced such a problem. Ok, will try to solve.
Re: How can I draw a thinner line with wxPen?
Yes, now changed the windows scale from 125 to 100 % and all become clear and precise.
Re: How can I draw a thinner line with wxPen?
In VS, project properties -> Manifest Tool -> Input and Output, you can set the DPI awareness flag.
Use the source, Luke!