Click here to Skip to main content
15,896,369 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Here is my simple code but it give me nothing altho the RGB values are in the program:
'-------------------------------------Picture color change--------------------
        Dim bm As Bitmap = New Bitmap("C:\trash\Babymono100.bmp")

        Dim x

        Dim y

        For y = 0 To bm.Height - 1

            For x = 0 To bm.Width - 1

                Dim c As Color = bm.GetPixel(x, y)

                TextBox1.Text = c.R

                For i = 1 To 10000


                    If c.R = DataGridViewGray.Rows(i).Cells(1).Value Then
                        bm.SetPixel(x, y, Color.FromArgb(DataGridViewRed.Rows(i).Cells(1).Value, DataGridViewGreen.Rows(i).Cells(1).Value, DataGridViewBlue.Rows(i).Cells(1).Value))

                        Exit For
                    End If

                Next
            Next
        Next
        PictureBox1.Image = bm

'I have Already 4 different DataGridView for GrayScale,Red,Green and Blue colors
I just need to determine the 3 RGB color related to the selected GrayScale color
Posted
Updated 5-May-14 21:50pm
v2
Comments
José Amílcar Casimiro 5-May-14 12:57pm    
What is the problem?

1 solution

1. You have a black and white image which means that all of the R,G,B values are equal.
2. You scan the 10000 rows of the data grid looking for a match to the R value and then set all of the R,G,B values to that same value.
3. They already were that value (see #1) so this doesn't do anything.
4. The R value is a byte value (0..255) so more than 256 rows is pointless.

Are you trying to accomplish some sort of "false color" mapping?
If so, the data grid should have separate R,G,B columns, and be ordered by the desired mapping so it can be indexed directly instead of searching.
I.e. Rows(0) should have the false color for intensity==0 (black) in the source image,
Rows(1) should have the false color for intensity==1 in the source image,
...
Rows(255) should have the false color for intensity==255 (white) in the source image.
 
Share this answer
 
Comments
Abhinav S 5-May-14 13:23pm    
5.
Matt T Heffron 5-May-14 13:41pm    
Thanks

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900