Setting Pixel Colors Programmatically in VB 2005

F

fripper

In VB 2005ave a I have a picture control ("pix") on which I want to set each
pixel color according to a variable, X, that has been calculated (I'm
drawing fractals from the Mandelbrot Set). I use the statement:

pix.SetPixel(i, j, myColor)

where i and j are the coordinates of the pixel and myColor is a variable of
type Color. Now X has a maximum value that it can attain (call it LimitX)
and I want the color of a given pixel to be some function of the value of X
for that pixel as a percentage of LimitX. For example, I could calculate
int(csng(X / LimitX) * 255) and use that value as the red, green and blue
components of myColor. My problem is I don't know how to set the RGB
components of myColor. I've tried using the FromArgb method but without
success.

Ideally I would like the user to be able to select two colors (call them A
and B) and then let myColor be in the range A to B based on value of X.

Can someone talk about setting pixel colors programatically ... or direct me
to an article that talks about it?

Thanks very much.
 
G

Guest

fripper said:
In VB 2005ave a I have a picture control ("pix") on which I want to set each
pixel color according to a variable, X, that has been calculated (I'm
drawing fractals from the Mandelbrot Set). I use the statement:

pix.SetPixel(i, j, myColor)

where i and j are the coordinates of the pixel and myColor is a variable of
type Color. Now X has a maximum value that it can attain (call it LimitX)
and I want the color of a given pixel to be some function of the value of X
for that pixel as a percentage of LimitX. For example, I could calculate
int(csng(X / LimitX) * 255) and use that value as the red, green and blue
components of myColor. My problem is I don't know how to set the RGB
components of myColor. I've tried using the FromArgb method but without
success.

Ideally I would like the user to be able to select two colors (call them A
and B) and then let myColor be in the range A to B based on value of X.

Can someone talk about setting pixel colors programatically ... or direct me
to an article that talks about it?

Thanks very much.

I don't know much about it but you can use the GetPixel and SetPixel
methods of a bitmap object. Might be able to do what you want w/ it

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top