I'm having a problem in c# where when i try to fill an entire 8x8px .bmp file with black it doesn't do anything and there are no errors here is my code:
using System;
using System.Windows;
using System.Drawing;
namespace Data_Block_Test
{
class Program
{
static string GetBytesFromBinaryString(String str, String output)
{
string result = "";
string s = str.Replace(" ", String.Empty); ;
while (s.Length > 0)
{
var first8 = s.Substring(0, 8);
s = s.Substring(8);
var number = Convert.ToInt32(first8, 2);
result += (char)number;
}
return result;
}
static void Main(string[] args)
{
string output1 = "";
Console.WriteLine(GetBytesFromBinaryString("01110011 01110101 01110011", output1));
Bitmap img = new Bitmap("image.png");
for (int x = 0; x < img.Width; x++)
{
for (int y = 0; y < img.Height; y++)
{
Console.WriteLine("before: x = {0}, y = {1}, argb = {2}", x, y, img.GetPixel(x, y));
img.SetPixel(x, y, System.Drawing.Color.Black);
Console.WriteLine("after: x = {0}, y = {1}, argb = {2}", x, y, img.GetPixel(x, y));
}
}
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}
im filling it pixel by pixel to experiment for something
edit: also please ignore GetBytesFromBinaryString()
and all references to it because it is unrelated to what i am trying to do