Click here to Skip to main content
15,910,234 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How can I set or change in global printer setting ? Pin
AhMan17-Dec-02 23:41
AhMan17-Dec-02 23:41 
GeneralRe: How can I set or change in global printer setting ? Pin
Christian Graus18-Dec-02 9:43
protectorChristian Graus18-Dec-02 9:43 
AnswerRe: How can I set or change in global printer setting ? Pin
Ravi Bhavnani18-Dec-02 10:42
professionalRavi Bhavnani18-Dec-02 10:42 
GeneralRe: How can I set or change in global printer setting ? Pin
AhMan18-Dec-02 15:44
AhMan18-Dec-02 15:44 
GeneralRotated Font - GetTextExtentPoint32 Pin
Braulio Dez17-Dec-02 22:49
Braulio Dez17-Dec-02 22:49 
GeneralSlider control ... Pin
Neha17-Dec-02 19:00
Neha17-Dec-02 19:00 
GeneralRe: Slider control ... Pin
Ravi Bhavnani18-Dec-02 10:47
professionalRavi Bhavnani18-Dec-02 10:47 
QuestionHow should I set a pixels color? Pin
rbc17-Dec-02 18:44
rbc17-Dec-02 18:44 
Hi,

I am trying to write a simple Mandelbrot set Visual C++ program.

I assume that I am not handeling the setting the color of a pixel
correctly.

Here's some of my code ...
<br />
...<br />
void CMand_View::OnDraw(CDC* pDC)<br />
{<br />
...<br />
	for( int i=0; i<320; i++ ) {<br />
		for( int j=0; j<200; j++ ) {<br />
			int c = CMand_View::Mandel_calcColor( i, j );<br />
			pDC->SetPixel(i,j, PALETTEINDEX(c));<br />
		}<br />
	}<br />
}<br />
...<br />
double CManel_View::Mandel_Abs ( double real, double img ) {<br />
	double rc = real * real + img * img;<br />
	return sqrt( rc );<br />
}<br />
<br />
int CMand_View::Mandel_calcColor( int X, int Y ) {<br />
	<br />
	int N;         		//  WHILE-loop control variable <br />
	double XPos, YPos;	// The real and imaginary parts of C<br />
	double RealPart; 		// The real part of Z<br />
	double ImagPart; 		// The imaginary part of Z<br />
	int AbsZ;     		// BOOLEAN;<br />
	double Temp;<br />
<br />
        double width = 320.0;<br />
        double height = 200.0;<br />
<br />
	N 		= 0;<br />
	AbsZ 		= TRUE;<br />
	RealPart 	= 0;<br />
	ImagPart 	= 0;<br />
	XPos 		= X / width  * (XMax - XMin) + XMin;<br />
	YPos 		= Y / height * (YMax - YMin) + YMin;<br />
<br />
	while ( (N < Iterations) && (AbsZ == TRUE) ) {<br />
		N++;<br />
		Temp 		= (RealPart*RealPart) - (ImagPart*ImagPart) + XPos;<br />
		ImagPart 	= 2.0 * ImagPart * RealPart + YPos;<br />
		RealPart 	= Temp;<br />
		AbsZ 		= (( CMand_View::Mandel_Abs (ImagPart, RealPart) <= Bailout) ? TRUE : FALSE);<br />
	} //end while<br />
<br />
	if (AbsZ == 0 ) {<br />
		return (N + sColor) % Colors;<br />
	} else {<br />
		return 0;<br />
	}<br />
} //end calcColor<br />
<br />


I think that this ...
<br />
			pDC->SetPixel(i,j, PALETTEINDEX(c));<br />

... is not right. Confused | :confused:
AnswerRe: How should I set a pixels color? Pin
Christian Graus17-Dec-02 18:50
protectorChristian Graus17-Dec-02 18:50 
GeneralRe: How should I set a pixels color? Pin
rbc17-Dec-02 19:00
rbc17-Dec-02 19:00 
GeneralRe: How should I set a pixels color? Pin
Christian Graus17-Dec-02 19:36
protectorChristian Graus17-Dec-02 19:36 
AnswerRe: How should I set a pixels color? Pin
Chris Losinger17-Dec-02 18:51
professionalChris Losinger17-Dec-02 18:51 
GeneralRe: How should I set a pixels color? Pin
rbc17-Dec-02 18:56
rbc17-Dec-02 18:56 
GeneralRe: How should I set a pixels color? Pin
Chris Losinger17-Dec-02 18:59
professionalChris Losinger17-Dec-02 18:59 
GeneralRe: How should I set a pixels color? Pin
rbc17-Dec-02 19:11
rbc17-Dec-02 19:11 
GeneralRe: How should I set a pixels color? Pin
Chris Losinger17-Dec-02 19:15
professionalChris Losinger17-Dec-02 19:15 
GeneralRe: How should I set a pixels color? Pin
rbc17-Dec-02 19:21
rbc17-Dec-02 19:21 
GeneralRe: How should I set a pixels color? Pin
Chris Losinger17-Dec-02 19:29
professionalChris Losinger17-Dec-02 19:29 
AnswerRe: How should I set a pixels color? Pin
rbc17-Dec-02 19:44
rbc17-Dec-02 19:44 
Generalhelp please!!!!!!! Pin
jinma7817-Dec-02 18:43
jinma7817-Dec-02 18:43 
GeneralRe: help please!!!!!!! Pin
Christian Graus17-Dec-02 18:49
protectorChristian Graus17-Dec-02 18:49 
GeneralRe: help please!!!!!!! Pin
Chris Losinger17-Dec-02 18:53
professionalChris Losinger17-Dec-02 18:53 
GeneralConvert from UTC to a local time somewhere in the world Pin
Uwe Keim17-Dec-02 18:40
sitebuilderUwe Keim17-Dec-02 18:40 
GeneralRe: Convert from UTC to a local time somewhere in the world Pin
Ted Ferenc17-Dec-02 22:19
Ted Ferenc17-Dec-02 22:19 
GeneralRe: Convert from UTC to a local time somewhere in the world Pin
Ted Ferenc17-Dec-02 22:22
Ted Ferenc17-Dec-02 22:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.