0

I have a system that captures screenshots from different systems and on different ways. These images are used by different clients, e.g. image comparison, OCR, displaying in GUI, logging etc.

Currently I designed my interfaces to use BitmapSource. But that showed difficulties with the dispatcher beeing created each time a BitmapSource was initialized on a thread without dispatcher. Issue Description

Now I am looking for a simple image interchange format that includes the essential information of an image. The special clients will convert this format to their own formats anyway (BitmapSource in WPF GUI, Mat in OpenCVSharp library, Pix in Tesseract OCR ...)

I tend to use Bitmap from System.Drawing namespace now, but this is also complex and somehow tied to Windows Forms. But it has already some conversion features and has loading and saving capabilities. Also, 3rd party libraries tend to offer conversion from Bitmap to their own format.

So is it appropriate to use Bitmap from System.Drawing as an image interchange format in class libraries (working and initializing in threads other than the GUI thread) or should I rather create an own implementation that carries the required information to represent an image? Or is there a simple independent image format already available somewhere?

Creepin
  • 482
  • 4
  • 20
  • What issues did you have using `Bitmap` to solve this? – mjwills Nov 08 '18 at 11:26
  • I'm using raw arrays of colors internally for a similar purpose but in the end what i expose are Bitmaps, i'd also like to know which issued you faced trying to use System.Drawing.Bitmap. – Ronan Thibaudau Nov 08 '18 at 11:27
  • @RonanThibaudau Currently I am just thinking of using `Bitmap`. I just wanted to go sure to not face any similar or different problems I faced with `BitmapSource`. So `Bitmap` would be my preference for the change. When using your raw array of colors, did you noticed any conversion difficulties since you are using a fixed format? – Creepin Nov 08 '18 at 15:47
  • @Creepin For my use case i'm using a single fixed format internally so things are pretty easy really, just have to convert from that to bitmap and back whenever i need to work outside my lib – Ronan Thibaudau Nov 08 '18 at 16:24
  • @RonanThibaudau and is conversion loss an issue? Or is the color you use for your array of a high color depth? So I mean if your source image is 32bit do you handle it as 24bit? Do you consider the alpha channel? – Creepin Nov 08 '18 at 17:15
  • @Creepin I can't really talk about that as none of this is used in my situation (i use a single internal format and a single bitmap format with the same bpp for each, i don't need the alpha channel) – Ronan Thibaudau Nov 09 '18 at 06:23
  • @RonanThibaudau Nevertheless, thanks for your suggestions, I will try a bit with a color array and else choose the `Bitmap` – Creepin Nov 09 '18 at 13:49

0 Answers0