Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Processing images without GDI+ in C#

For some reasons, I need to write few image processing functions without using GDI+. I need to be able to do the following operations on images.

  • Draw some shapes on existing images (mostly rectangle with a plain background color). Regularly i do this using Graphics.DrawImage() function in GDI+.
  • Draw texts on existing image. Regularly I do this using Graphics.DrawString() function in GDI+
  • Save image to MemoryStream. Regularly I do this by Image.Save(stream, imgformat) function in GDI+
  • Get image bytes. Regularly I do this by MemoryStream.ToArray() function. I need bytes because I need to be able to send image to HttpContext() using the context.Response.BinaryWrite(imageBytes) method.

I've already looked at AForge.net, but it is missing Image.Save() method. It uses native Bitmap.Save() method of GDI+. So I seem to have no way of surviving GDI+ with AForge.

I've also looked at OpenCV and its .NET wrapper Emgu, but after 2 days of hard try, I was not able to successfully integrate the project into my own project (I know this sound silly, but that is truth. Following all the tutorials, probably 20+ SO posts on this did not help, because my solution structure is a little bit more than (more complex) a regular solutions).

How can I achieve this? Show me some way please. Have you even found yourself in such a situation (situation where you need to process images, but no GDI+)? What are the other libraries that could help me?

like image 933
Zafar Avatar asked Apr 25 '26 23:04

Zafar


1 Answers

There's a recent project that's gathering momentum called, appropriately, "ImageProcessor": https://github.com/JimBobSquarePants/ImageProcessor - NuGet reports over 344,000 downloads as of June 2016.

Scott Hanselmann did a feature on it about 8 months ago, explaining the motivation given that .NET Core does not have System.Drawing (and I note that Windows Azure does not officially support GDI in Website Roles): http://www.hanselman.com/blog/RFCServersideImageAndGraphicsProcessingWithNETCoreAndASPNET5.aspx

like image 72
Dai Avatar answered Apr 27 '26 14:04

Dai