Blogadda

Blogadda
Visit BlogAdda.com to discover Indian blogs

Friday, March 27, 2009

First convert Hex to Byte Array(http://www.codeproject.com/KB/recipes/hexencoding.aspx)



string hexString = txtHex.Text;

int discarded;

txtByteCount.Text = ((int)HexEncoding.GetByteCount(hexString)).ToString();

txtLength.Text = hexString.Length.ToString();

byte[] byteArray = HexEncoding.GetBytes(hexString, out discarded);

txtDiscard.Text = discarded.ToString();

string temp = "";

for (int i=0; i


{

temp += byteArray[i].ToString("D3") + " ";

}

txtByte.Text = temp;

txtHex2.Text = HexEncoding.ToString(byteArray);






Then Convert Byte Array to Image

(https://secure.codeproject.com/KB/recipes/ImageConverter.aspx?fid=337686&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2182648)

public Image byteArrayToImage(byte[] byteArrayIn)

{

MemoryStream ms = new MemoryStream(byteArrayIn);

Image returnImage = Image.FromStream(ms);

return returnImage;

}






After that image to any type (gif etc)

public byte[] imageToByteArray(System.Drawing.Image imageIn)

{

MemoryStream ms = new MemoryStream();

imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);

return ms.ToArray();

}






Also



img=Image.FromFile("test.jpg");
img.Save("test.png",ImageFormat.Jpeg); //so simple :-)






Also the useful links



http://www.codeproject.com/KB/web-image/pnguploader.aspx

http://msdn.microsoft.com/en-us/library/ktx83wah.aspx

No comments: