I want to rotate the image to 45 degrees by Y axis, what should I do?
bool func1()
{
QImage image(3840, 2160, QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::red);
QTransform t;
t.translate(image.width() / 2.0, image.height() / 2.0);
t.rotate(-45, Qt::YAxis);
t.translate(-image.width() / 2.0, -image.height() / 2.0);
image = image.transformed(t);
return image.save("/tmp/func1.png");
}
The func1 is output the "QImage: out of memory, returning null image" error
message and return false. This behavior is related to the size of the image. If
it is a 1000x1000 image, it can be successful. But the rotated image is
different as use GIMP, is this a Qt bug?
bool func2()
{
QImage image(3840, 2160, QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::red);
QTransform t;
t.translate(image.width() / 2.0, image.height() / 2.0);
qreal b = qDegreesToRadians(-45);
qreal sina = qSin(b);
qreal cosa = qCos(b);
QTransform tmp(cosa, 0, -sina / image.width(), // There is "-sina / 1024"
in QTransform::rotate
0, 1, 0,
0, 0, 1);
t = tmp * t;
t.translate(-image.width() / 2.0, -image.height() / 2.0);
image = image.transformed(t);
return image.save("/tmp/func2.png");
}
The func2 is return true. I can't understand the QTransform::rotate, What is
the "inv_dist_to_plane"? Why is its value 1/1024?
_______________________________________________
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development