良い。これは、私が昔、遅いハードウェアで行っていたトリックです。基本的に、イメージ バッファは必要な 2 倍の幅で割り当てられ、先頭に 1 行追加されます。バッファーの左側にイメージをビルドします。次に、バッファー内で一度に 1 ピクセルずつ進めるバッファーで画像を繰り返し描画します。
int w = 200;
int h = 100;
int rowBytes = w * sizeof(QRgb) * 2; // line buffer is twice as the width
QByteArray buffer(rowBytes * (h + 1), 0xFF); // 1 more line than the height
uchar * p = (uchar*)buffer.data() + rowBytes; // start drawing the image content at 2nd line
QImage image(p, w, h, rowBytes, QImage::Format_RGB32); // 1st line is used as the padding at the start of scroll
image.fill(qRgb(255, 0, 0)); // well. do something to the image
p = image.bits() - rowBytes / 2; // start scrolling at the middle of the 1st (blank) line
for(int i=0;i<w;++i, p+=sizeof(QRgb)) {
QImage scroll(p, w, h, rowBytes, QImage::Format_RGB32); // scrool 1 pixel at a time
scroll.save(QString("%1.png").arg(i));
}
画像のオフセットを変更してまっすぐに描画するよりも速くなるかどうかはわかりません。今日のハードウェアは非常に強力で、多くの古いトリックが役に立たなくなります。でも、あいまいなトリックをするのは楽しいです。:)