0

I have a QImage of size 12x12 in GIF format. I want to rotate it on certain angle with very high frequency. My application involves a robot so when it changes its orientation(which it does very frequently) my QImage in simulation should also be rotated but it causes loss of information. I am doing it something like below.

 robot_transform.rotate(angle);
*robot2 = robot->transformed(robot_transform,Qt::SmoothTransformation);
*robot2=  robot2->scaled(12,12, Qt::KeepAspectRatio,Qt::SmoothTransformation);

I need suggestions that whats wrong in this approach and secondly is there any other optimal approach for the desired application? Thanks

Victor Yan
  • 3,339
  • 2
  • 28
  • 28

2 Answers2

1

I would increase the resolution of the source image to at least double. Rotating an image to non-90-degree angles will cause loss of pixel information. An higher res source can compensate for that.

Most sprite based animations use pre-rendered images for each possible angle.

Stephen Chu
  • 12,724
  • 1
  • 35
  • 46
0

The problem is the scaling afterwards, you need to crop the center of the image. You can do this with QImage::copy.

bjoernz
  • 3,852
  • 18
  • 30