Click here to Skip to main content
12,747,366 members (36,344 online)
Rate this:
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 21:53pm
Rate this: bad
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.
Espen Harlinn 6-Jan-13 5:29am
Good point
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You already posted this question at[^]; please do not post in multiple forums.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170215.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2017
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