bmp.ToByteArray(ImageFormat.Bmp).Length 3145782 int
but the file system is displayed as 2,25 MB (2.359.350 bytes) and Size on disk 2,25 MB (2.363.392 bytes)
Why is there a difference and how can I determine the correct size of the bitmap in the byte [] form?
string appPath = Application.StartupPath;
var bmp = new Bitmap(Image.FromFile(appPath + "\\Images\\Penguins.bmp"));
public static byte[] ToByteArray(this Image image, ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms, format);
return ms.ToArray();
}
}
Windows 7 / NTFS
source
share