Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to compare the <code>ARGB</code> values of color</p> <pre><code>Dim cw As New Color cw = Color.Black dim curPixColor as Color = b.GetPixel(x, y) If curPixColor.ToArgb = cw.ToArgb Then nii.SetPixel(x, y, Color.Red) End If </code></pre> <p>Or you should use the Equality Operator</p> <pre><code>Dim cw As New Color cw = Color.Black dim curPixColor as Color = b.GetPixel(x, y) If Color.op_Equality(curPixColor, cw) Then nii.SetPixel(x, y, Color.Red) End If </code></pre> <p>Reference:<a href="http://msdn.microsoft.com/en-us/library/system.drawing.color.op_equality(v=vs.110).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.drawing.color.op_equality(v=vs.110).aspx</a></p> <p>Edit: As you are getting pixel from a bmp there is no transparency supported. so your comparing color should be</p> <pre><code>cw = Color.FromArgb(0,0,0,0) </code></pre> <p><strong>Edit2</strong>: you are reading pixed from <code>nii</code> you should be reading from <code>b</code></p> <pre><code>dim curPixColor as Color = b.GetPixel(x, y) </code></pre> <p>full code should be something like (tested)</p> <pre><code> Dim b As Bitmap = New Bitmap("D:\test.bmp") ' Make Image Indexed Dim nii As New Bitmap(b.Width, b.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb) For y As Integer = 0 To nii.Height - 1 For x = 0 To nii.Width - 1 Dim cw As New Color cw = Color.Black Dim curPixColor As Color = b.GetPixel(x, y) If curPixColor.ToArgb() = cw.ToArgb() Then nii.SetPixel(x, y, Color.Red) Else nii.SetPixel(x, y, curPixColor) End If Next Next PictureBox1.Image = Image.FromFile("D:\test.bmp") PictureBox2.Image = nii </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload