Would it be possible to use a library for this, like [QImage](https://qt-project.org/doc/qt-4.8/qimage.html)?