- Present everything as small, composable components
- Avoid implicit copying and prefer lazy evaluation
- Use templates for efficient code
From its first iteration, all components of the image processing package were templated by the color type. This is not a conventional way to implement graphics libraries – most libraries abstract away the exact color type the image uses behind an OOP interface, or they simply convert all images to a single in-memory pixel format. However, for most cases, this is wasteful and inefficient – usually, the programmer already knows the exact format that an image will be in, with notable exceptions being applications in which the image data comes from user input (e.g. image editors). Instead, this library declares all image types as templates, with the type indicating the image’s color being a template parameter.
I’m rather pleased with the result of this overhaul, so I’d like to share some highlights in this article. Continue reading