【发布时间】:2016-03-14 13:58:01
【问题描述】:
我的项目要求是我可以创建一个宽度最大为 36000 像素(高度小得多)的图像。
(图片来自QGraphicsScene)。
我遇到了一个限制:QPainter 限制了光栅绘画的设备大小:
void QRasterPaintEnginePrivate::systemStateChanged()
{
deviceRectUnclipped = QRect(0, 0,
qMin(QT_RASTER_COORD_LIMIT, device->width()),
qMin(QT_RASTER_COORD_LIMIT, device->height()));
....
}
// This limitations comes from qgrayraster.c. Any higher and
// rasterization of shapes will produce incorrect results.
const int QT_RASTER_COORD_LIMIT = 32767;
(我的故障排除尝试...Rendering a large QGraphicsScene on a QImage clips it off)
所以...我想,我可以创建 2 个图像然后添加它们吗? (一个在对方的末尾)
if(wOutput > 32767)
{
QImage image1 = QImage(32767, hOutput, QImage::Format_Mono);
image1.fill(QColor(Qt::white).rgb());
QRectF source(0, 0, 32767, hOutput);
QRectF target(0, 0, 32767, hOutput);
QPainter painter;
painter.begin(&image1);
outputScene->render(&painter, target, source);
painter.end();
QImage image2 = QImage(wOutput - 32767, hOutput, QImage::Format_Mono);
image2.fill(QColor(Qt::white).rgb());
source = QRectF(32767, 0, wOutput - 32767, hOutput);
target = QRectF(0, 0, wOutput - 32767, hOutput);
painter.begin(&image2);
outputScene->render(&painter, target, source);
painter.end();
// now create a combination, add image2 at the end of image1
QImage image = QImage(wOutput, hOutput, QImage::Format_Mono);
painter.begin(&image);
painter.drawImage(0, 0, image1);
painter.drawImage(32767, hOutput, image2);
painter.end();
}
else
{
// just create the image
}
看起来很合乎逻辑...但输出未显示image2。显然...我使用的是相同的光栅绘画...具有相同的限制!
还有什么其他方法可以在另一张图片的末尾添加一张图片? (注意 - 我的“大”尺寸是“宽度”,所以我什至不认为我可以使用 scanline 更快地复制像素)
【问题讨论】:
-
为什么不想使用扫描线来获取像素数据并复制呢?
-
@Fabio - 我可以 - 但如何