I want to convert a string into a bitmap or something I can show in a pixelbox.
My string looks like this:
string rxstring = \"01001001002002002003003003
Try converting the string to a byte array and loading it into a memory stream. Once in the stream, you should be able to convert to an image.
List splitBytes = new List();
string byteString = "";
foreach (var chr in testString)
{
byteString += chr;
if (byteString.Length == 3)
{
splitBytes.Add(Convert.ToByte(byteString));
byteString = "";
}
}
if (byteString != "")
splitBytes.AddRange(Encoding.ASCII.GetBytes(byteString));
using (var ms = new MemoryStream(splitBytes.ToArray()))
{
var img = System.Drawing.Image.FromStream(ms);
//do something with image.
}
EDIT: Added updated code. This was tested by loading an image of my own and converting the bytes into a string, then converting them back into a byte array using the above code and I successfully loaded the image from a string.
string testString = "255216255224000016074070073070000001001001000096000096000000255225000104069120105102000000077077000042000000000008000004001026000005000000000001000000000062001027000005000000000001000000000070001040000003000000000001000002000000001049000002000000000018000000000078000000000000000000000096000000000001000000000096000000000001080097105110116046078069084032118051046053046049049000255219000067000002001001002001001002002002002002002002002003005003003003003003006004004003005007006007007007006007007008009011009008008010008007007010013010010011012012012012007009014015013012014011012012012255219000067001002002002003003003006003003006012008007008012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012012255192000017008000004000004003001034000002017001003017001255196000031000000001005001001001001001001000000000000000000000000001002003004005006007008009010011255196000181016000002001003003002004003005005004004000000001125001002003000004017005018033049065006019081097007034113020050129145161008035066177193021082209240036051098114130009010022023024025026037038039040041042052053054055056057058067068069070071072073074083084085086087088089090099100101102103104105106115116117118119120121122131132133134135136137138146147148149150151152153154162163164165166167168169170178179180181182183184185186194195196197198199200201202210211212213214215216217218225226227228229230231232233234241242243244245246247248249250255196000031001000003001001001001001001001001001000000000000000000001002003004005006007008009010011255196000181017000002001002004004003004007005004004000001002119000001002003017004005033049006018065081007097113019034050129008020066145161177193009035051082240021098114209010022036052225037241023024025026038039040041042053054055056057058067068069070071072073074083084085086087088089090099100101102103104105106115116117118119120121122130131132133134135136137138146147148149150151152153154162163164165166167168169170178179180181182183184185186194195196197198199200201202210211212213214215216217218226227228229230231232233234242243244245246247248249250255218000012003001000002017003017000063000252225248089251085248195193031007060033030133127054137107121166121143107103121116176043069052182202085076167111238224143056234193152252204073040162128063255217";
EDIT: Added a sample string of the image I used to test the above code.