Home All Groups Group Topic Archive Search About

Setting Individual Pixel Colors in VB 2005

Author
22 Jan 2006 1:38 AM
fripper
I want to generate a graphic in a picture box control where the color of
each pixel is determined by particular values calculated for each pixel.
These values are manipulated in such a way that I come up with three values
(each in the range 0-`55) and I want to use these for the RGB values of the
color of the associated pixel.  My question is:  In VB 2005 how do I set a
particular pixel to a color with a given set of RGB values?  In VB 6 I used
the PSET function but it is not available in VB 2005.
Thanks.

Author
22 Jan 2006 12:16 PM
Ken Tucker [MVP]
Hi,

        Use the graphics class fillellipse method with a diameter of 1.

Ken
----------------
Show quoteHide quote
"fripper" <yo***@indiana.edu> wrote in message
news:%23mQeSSvHGHA.2912@tk2msftngp13.phx.gbl...
>I want to generate a graphic in a picture box control where the color of
>each pixel is determined by particular values calculated for each pixel.
>These values are manipulated in such a way that I come up with three values
>(each in the range 0-`55) and I want to use these for the RGB values of the
>color of the associated pixel.  My question is:  In VB 2005 how do I set a
>particular pixel to a color with a given set of RGB values?  In VB 6 I used
>the PSET function but it is not available in VB 2005.
> Thanks.
>
>
Author
24 Jan 2006 5:39 PM
Jay B. Harlow [MVP - Outlook]
In addition to the other comments:

Are you drawing on the screen or a Bitmap?

You can use Bitmap.SetPixel to set an individual Pixel on a bitmap.

Something like:

        Dim bm As New Bitmap(256, 256)
        For x As Integer = 0 To 256- 1
            For y As Integer = 0 To 256- 1
                bm.SetPixel(x, y, Color.FromArgb(x, y, 0))
            Next
        Next
        Me.PictureBox1.Image = bm


--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


Show quoteHide quote
"fripper" <yo***@indiana.edu> wrote in message
news:%23mQeSSvHGHA.2912@tk2msftngp13.phx.gbl...
|I want to generate a graphic in a picture box control where the color of
| each pixel is determined by particular values calculated for each pixel.
| These values are manipulated in such a way that I come up with three
values
| (each in the range 0-`55) and I want to use these for the RGB values of
the
| color of the associated pixel.  My question is:  In VB 2005 how do I set a
| particular pixel to a color with a given set of RGB values?  In VB 6 I
used
| the PSET function but it is not available in VB 2005.
| Thanks.
|
|