bitmap to byte array c#
public static byte[] ImageToByteArray(Image img)
{
using (var stream = new MemoryStream())
{
img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
return stream.ToArray();
}
}public static class ImageExtensions
{
public static byte[] ToByteArray(this Image image, ImageFormat format)
{
using(MemoryStream ms = new MemoryStream())
{
image.Save(ms, format);
return ms.ToArray();
}
}
}
Also in C#:
- c# variable
- c# Sleep
- c# get desktop path
- unity onclick object
- how to add array to list in c#
- c# get list of all class fields
- asp.net c# write string to text file
- c# post request
- c# new thread
- player script unity
- c# regex replace
- asp textarea
- C# .net core convert to int round up
- c# datetime dd/mm/yyy hh:mm:ss
- c# type of generic is string
- foreach c#
- c# communicate with arduino
- string isnullorempty vs isnullorwhitespace
- c# tab character
- C# resize window without title bar
- c# linq join multiple conditions
- get all child gameObject of gameObject C#
- ASP select box all states