By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 1,942 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

Starfield

P: n/a
Hi !

I'm new to C# and want to start by making a starfield with stars coming from
the middle and ou while getting brighter.

First of all, how to I make a single pixel ? And secondly, how to do this
fast without any flicker at all ?

I made alot of this stuff in assembler in C64 and C Amiga, with the speed of
computers today it should be possible to have alot of stars without any
flicker at all

I have searched the web alot and one example I found on how to make a pixel
seems kinda silly and slow, see this

Drawing a single pixel in C#

I am writing a control that needs to display a grid (similar to the VS.NET
IDE) as the background. Now in the "old days" you could call the function
SetPixel to draw a single pixel on a device context. However, the .NET
Graphics object does not have such an API, so how do you do it without
resorting to P/Invoke? I found a solution on the web and here it is...
// Create a 1 x 1 bitmap and set the color
Bitmap pt = new Bitmap(1, 1);
pt.SetPixel(0, 0, Color.Gray);
// Draw bitmap on Graphics surface
e.Graphics.DrawImageUnscaled(pt, x, y);
It's pretty simple, but it took me a few minutes of experimentation before
looking to the web for an answer. To quote Star Trek, "Engineers love to
change things."
How can this be make better !

Also if anyone know of graphic demos made with c# please share the link !

Hope some of you can guide me in the right direction ( Using VS2005 )

Thanx

Jack

--------------------------------------------------------------------------------
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at få 12297 spam-mails
Betalende brugere får ikke denne besked i deres e-mails.
Hent en gratis SPAMfighter her.
Sep 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Jack Nielsen" <no_spam ja**********@get2net.dkwrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
Hi !

I'm new to C# and want to start by making a starfield with stars coming
from the middle and ou while getting brighter.

First of all, how to I make a single pixel ? And secondly, how to do this
fast without any flicker at all ?
Fill a 1*1 pixel Rectangle.
e.Graphics.FillRectangle(Brushes.White, 0, 0, 1, 1);

Double Buffer for flickerless painting.
Aren't stars supposed to flicker ;-)

Take a look at Bob Powells GDI+ FAQ, where you should find the answers to
these as well as some of your follow up questions:
http://www.bobpowell.net/faqmain.htm

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
Sep 21 '06 #2

P: n/a
Are there any plans that GDI will be hardware acc. ?

Jack
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]skrev i
en meddelelse news:OE**************@TK2MSFTNGP06.phx.gbl...
"Jack Nielsen" <no_spam ja**********@get2net.dkwrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
>Hi !

I'm new to C# and want to start by making a starfield with stars coming
from the middle and ou while getting brighter.

First of all, how to I make a single pixel ? And secondly, how to do this
fast without any flicker at all ?

Fill a 1*1 pixel Rectangle.
e.Graphics.FillRectangle(Brushes.White, 0, 0, 1, 1);

Double Buffer for flickerless painting.
Aren't stars supposed to flicker ;-)

Take a look at Bob Powells GDI+ FAQ, where you should find the answers to
these as well as some of your follow up questions:
http://www.bobpowell.net/faqmain.htm

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
--------------------------------------------------------------------------------
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at få 12319 spam-mails
Betalende brugere får ikke denne besked i deres e-mails.
Hent en gratis SPAMfighter her.
Sep 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.