On Friday, 1 July 2016 at 11:09:49 UTC, Relja Ljubobratovic wrote:
When loading images, bit depth should be determined in the runtime, depending on the image you'd be loading at the moment. Or am I wrong?
Generally most use cases for using an image library can be divided into:
1. You have full control over the images being loaded. This is the case when you're loading graphical assets for your application which otherwise doesn't concern itself for graphical work.
2. You're writing an image editor, or some other program that processes images out of your control, i.e. supplied by the user.
Generally the first case is by far the most common one (think GUI applications, video games...). In this case, since you already know or have control over the format of your images, there is no reason to burden your application with performance-killing abstraction layers - you should load and work in the format that your images already are.
Additionally, if necessary, it is easy to build such a runtime abstraction layer over a templated library by creating an algebraic type from only the set of formats that you want to support. Doing the inverse is impossible.
In case anyone from this thread haven't seen it, I have my own image library, which I wrote about here: https://blog.thecybershadow.net/2014/03/21/functional-image-processing-in-d/