I'm not sure if I've made anything wrong but I found Windows 8 has breaking changes when I'm using some simplest features in .NET framework. One of my machine is Windows 7 X64 with Visual Studio 2010 premium, the other is Windows 8 X64 with exactly the same Visual Studio. Both of the Win7 / Win8 system are downloaded as MSDN subscriber so they are all official. However for the following code:
static void Main(string[] args)
{
byte[] dataBytes = new byte[256 * 256 * 4 + 256];
MemoryStream resultStream = new MemoryStream();
DeflateStream deflateStream = new DeflateStream(resultStream, CompressionMode.Compress);
deflateStream.Write(dataBytes, 0, dataBytes.Length);
Console.WriteLine(resultStream.Length);//2330
Bitmap a = new Bitmap(256, 256);
MemoryStream memoryStream1 = new MemoryStream();
a.Save(memoryStream1, ImageFormat.Png);
byte[] byteArray1 = memoryStream1.ToArray();
Console.WriteLine(byteArray1.Length);//1275
Console.Read();
}
it returns 2330/1275 on Window 7 but returns 0/384 on Windows 8. the codes are identical and are both under .NET Framework 4 Client Profile.
So I did anything wrong or it is a breaking change on Windows 8?
Thanks very much in advance.
Thanks for all your help guys. For the first case I tried the following code
byte[] dataBytes = new byte[256 * 256 * 4 + 256];
MemoryStream resultStream = new MemoryStream();
DeflateStream deflateStream = new DeflateStream(resultStream, CompressionMode.Compress);
deflateStream.Write(dataBytes, 0, dataBytes.Length);
deflateStream.Close();
Console.WriteLine(resultStream.ToArray().Length);
and I got 2338 on Windows7 and 271 on Windows8. So seems Windows 8 does have done some optimizations to make the result stream smaller.