I need to set the least significant bits of some bytes (from an image).
For example, I have an image of width w and height h. Each element [w][h] is a pixel.
Sample data for the red channel (where I want to set the bits):
[0][0] = 01010111
[0][1] = 01010110
[0][2] = 01011110
[0][3] = 11111011
[0][4] = 01011010
[0][5] = 01100110
[0][6] = 01010101
[0][7] = 11010101
I want to change the bits in bold text into 00101010.
My code so far:
Dim img As New Bitmap(TextBox1.Text)
For w As Integer = 0 To img.Width - 1
For h As Integer = 0 To img.Height - 1
Dim pixel As Color = img.GetPixel(w, h)
If w < 4 AndAlso h < TextBox2.Text.Length Then
Dim pix As Integer = pixel.R
Dim pix2bin As String = Convert.ToString(pix, 2).PadLeft(8, "0")
How can I do this?