Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Created April 9, 2012 17:04
Show Gist options
  • Save rodolfofadino/2344766 to your computer and use it in GitHub Desktop.
Save rodolfofadino/2344766 to your computer and use it in GitHub Desktop.
ConvertImageToBytes
public byte[] ConvertImageToBytes(Image imageToConvert, System.Drawing.Imaging.ImageFormat formatOfImage)
{
byte[] ret;
try
{
using (var ms = new MemoryStream())
{
imageToConvert.Save(ms, formatOfImage);
ret = ms.ToArray();
}
}
catch (Exception) { throw; }
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment