I already tried your approach before, but my application is very time critical and I want to avoid unnecessary computation time! Is there a way to tell the transformation process which color to take for the void area pixels?

img = img.transformed(m); will convert the format() to QImage::Format_ARGB32_Premultiplied (you can check by adding qDebug() << img.format(); before img.save("3_rotated_inverted.bmp");) so you have to convert it back to Mono