C# looking for libraries/classes for fast-performing filter overlay
I apply filters to the incoming image with the request, and then send it back I process all this now using Bitmap, very convenient, but the performance suffers greatly. Are there any libraries/classes specifically for this purpose?
Converting from an incoming stream to an image
var Picture = new Bitmap(listenerContext.Request.InputStream);
Iterate over the pixels to set a new color. The GetPixel method is low-performance (as it seems to me)
for (int x = 0; x < bmp.Width; x++)
for (int y = 0; y < bmp.Height; y++) {
var temp = bmp.GetPixel(x,y);
bmp.SetPixel(x,y, Color.FromArgb(temp.A,temp.R,temp.G,temp.B));
}
Saving an image in response per request
Picture.Save(listenerContext.Response.OutputStream, ImageFormat.Png);
3
1 answers
I think the easiest way is to use FastBitmap, for example like this:
using(var fastBitmap = bitmap.FastLock())
{
fastBitmap.SetPixel(1, 1, Color.Red);//что-то делаем
};
Which is minimally different from using the usual Bitmap
; moreover, you do not need a reverse converter-when working, it changes the existing Bitmap
on which it was created.
2
Author: Alias, 2018-02-06 04:36:21