Answer the question
In order to leave comments, you need to log in
How to set a color for a number?
There is a code that converts a string to binary. Now we need to break these numbers into pixels. Ie 1 - white color, 0 - black color. We have to conditionally walk through the numbers, draw pixels if 1 or 0. How to do this?
Answer the question
In order to leave comments, you need to log in
Here, for example, filling a PictureBox with pixels in one row
var str = "hello world";
var sb = new StringBuilder();
foreach (var c in str)
{
sb.Append(Convert.ToString(c, 2));
}
str = sb.ToString();
var image = new Bitmap(str.Length, 1);
for (var index = 0; index < str.Length; index++)
{
var c = str[index];
switch (c)
{
case '1':
image.SetPixel(index,0, Color.Black);
break;
case '0':
image.SetPixel(index,0, Color.White);
break;
}
}
pictureBox1.Image = image;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question