Hi,
I have to convert bitmap to byte[] but compress rate when i use Encoder of .NET is not good.
I found Magick.NET with compress rate good!! Yeah!! Thanks dlemstra!
But performance of Magick.NET to convert MagickImage to bytes are high(about 300ms) . Encoder of .NET almost instantaneous (0-5ms)
Here is my test code:
Read: 6340
To byte array: 31159
Image resolution: 1366 * 768
Please tell me my code have some thing wrong? How to increase performance?
One again, thank U for written a useful lib
I have to convert bitmap to byte[] but compress rate when i use Encoder of .NET is not good.
I found Magick.NET with compress rate good!! Yeah!! Thanks dlemstra!
But performance of Magick.NET to convert MagickImage to bytes are high(about 300ms) . Encoder of .NET almost instantaneous (0-5ms)
Here is my test code:
byte[] bytes = null;
MagickImage mImage = new MagickImage();
Stopwatch total = new Stopwatch();
Stopwatch read = new Stopwatch();
Stopwatch toBytes = new Stopwatch();
// Stopwatch resize = new Stopwatch();
total.Start();
for (int i = 0; i < 100; i++)
{
read.Start();
// image is bitmap image object in memory
mImage.Read(image);
read.Stop();
//resize.Start();
//mImage.Resize(80);
//resize.Stop();
toBytes.Start();
bytes = mImage.ToByteArray(MagickFormat.WebP);
//mImage.Format = MagickFormat.WebP;
//mImage.Write("image.webp");
toBytes.Stop();
}
total.Stop();
Console.WriteLine("Time: {0}, {1}", read.ElapsedMilliseconds, bytes.ElapsedMilliseconds);
The result:Read: 6340
To byte array: 31159
Image resolution: 1366 * 768
Please tell me my code have some thing wrong? How to increase performance?
One again, thank U for written a useful lib