Does Qt allow to translate (or crop) images with sub-pixel accuracy?

The use case is a 2D map with a vehicle at the origin. The map shall also be translated in case the vehicle moves e.g. 0.5 pixels. I believe this should be feasible in principle using bilinear interpolation or similar.

Minimal example:

Qt Code:
  1. #include <QtWidgets/QApplication>
  2. #include <QtGui/QImage>
  3. #include <QLabel>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.  
  8. QApplication app(argc, argv);
  9.  
  10. // Parameters
  11. QString PATH_IMG_IN = "../img_test_rect.jpg";
  12. QString PATH_IMG_OUT = "../img_out.png";
  13. float TRANSLATE_IN_PX = 0.5;
  14.  
  15. // load image
  16. QImage img;
  17. img.load(PATH_IMG_IN);
  18.  
  19. // rotate image.
  20. QTransform trans;
  21. trans.translate(0,TRANSLATE_IN_PX);
  22. QImage img_new = img.transformed(trans, Qt::SmoothTransformation);
  23.  
  24. // save image
  25. img_new.save(PATH_IMG_OUT, nullptr, 100);
  26.  
  27. // optional: Get info about true transformation matrix
  28. QTransform trans_true = QImage::trueMatrix(trans, img.width(), img.height());
  29.  
  30. return app.exec();
  31. }
To copy to clipboard, switch view to plain text mode 


I also tried using "void QPainter::drawImage(const QPointF &point, const QImage &image)" without success. Moreover, I found a few threads without answer such as https://stackoverflow.com/questions/...48425_40552885

It seems to me that Qt does not enable this feature at the moment, but I am just guessing, not knowing.