Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
Hi all.
I need to draw a thick line with SetPixel API. I search very, but can't find any open source algorithm (Bresenham algorithm is one pixel, murphy algorithm is for line with more than 3 pixel thick, ... ).
If you can please help me.
Notice that I can not use CPen and other facilities in windows. I should use SetPixel.
Excuse me for bad English.
Posted 5-Jan-13 20:53pm
A_Fa1.4K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If you're going to do it with SetPixel(), you're going to have a lot of trouble. That will stuck your program. This is GDI we are talking about, which is a device independent high level graphical API. GDI has a quite long pipeline when we call a GDI drawing function. No. of calls to a drawing function slows your program than what it actually does.
 
For Example, both of the following functions will do the same, but will act as differently. Try using both functions and see the difference. (1st function uses a one call to draw a rectangle, but the 2nd uses 1000*1000, which is 1,000,000 function calls to the same function over and over) :
 
void DrawRect(HDC hdc)
{
	Rectangle(hdc, 0, 0, 1000, 1000);
}
 
void SetPixelRect(HDC hdc)
{
	int i,j;
	for(i=0; i<1000; i++)
	for(j=0; j<1000; j++)
	{
	SetPixel(hdc, i, j, RGB(0,0,0));
	}
}
 
It's always good to start things from the scratch. But for your purpose, GDI is not the best place. You need to code directly to the VGA to do so. Try google for that.
  Permalink  
v2
Comments
Espen Harlinn at 6-Jan-13 5:29am
   
Good point
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You already posted this question at http://www.codeproject.com/Messages/4465499/Thick-Line-Algorithm.aspx[^]; please do not post in multiple forums.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 735
1 OriginalGriff 385
2 CPallini 240
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,198
2 CPallini 4,740
3 George Jonsson 3,167
4 Gihan Liyanage 2,470


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100