用qt显示geotiff图片
Display geotiff images with qt
我目前正在尝试为在图像上投影 DSM(geotiff 文件)的脚本制作图形界面。我认为在进行一些计算之前同时显示图像和 DSM 是个好主意。
不幸的是,即使显示图像没有问题,我在尝试显示 DSM 时出现以下错误:
TIFFReadDirectory: Warning, foo: unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, foo: unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, foo: unknown field with tag 42112 (0xa480) encountered.
TIFFReadDirectory: Warning, foo: unknown field with tag 42113 (0xa481) encountered.
foo: Sorry, can not handle images with 32-bit samples.
QPixmap::scaled: Pixmap is a null pixmap
这是我目前正在尝试的:
QString s1 = QFileDialog::getOpenFileName(this, "Open a DSM", "/home", "Images (*.png *.xpm *.jpg *.tif *.tiff)");
ui->DSMPath->setText(s1);
QPixmap dispdsm(s1);
int w = ui->DSMDisplay->width();
int h = ui->DSMDisplay->height();
ui->DSMDisplay->setPixmap(dispdsm.scaled(w,h,Qt::KeepAspectRatio));
在网上搜索了一下,好像还没有解决办法
我明确表示我正在 Ubuntu 使用 QT 和 OpenCV 以及 Magick++ 库。
有人可以帮助我吗?
非常感谢:)
Qt 根本不支持您正在使用的格式的图像。您需要为 libgeotiff 使用自己的 QImageIOHandler
包装器。
Kuba Ober 是对的,但是对于那些想要显示 geotiff 图像而不定义自己的 QImageIOHandler
和使用 OpenCV 的人,您可以将 geotiff 图像作为 OpenCV 矩阵加载并将其转换为 QImage .
这里是我的转换:
QImage image= QImage((uchar*) dsm.data, dsm.cols, dsm.rows, dsm.step, QImage::Format_ARGB32_Premultiplied);
QPixmap dispdsm = QPixmap::fromImage(image);
其中 dsm
在我的 OpenCV 矩阵中,dispdsm
它的可显示版本。
我目前正在尝试为在图像上投影 DSM(geotiff 文件)的脚本制作图形界面。我认为在进行一些计算之前同时显示图像和 DSM 是个好主意。 不幸的是,即使显示图像没有问题,我在尝试显示 DSM 时出现以下错误:
TIFFReadDirectory: Warning, foo: unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, foo: unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, foo: unknown field with tag 42112 (0xa480) encountered.
TIFFReadDirectory: Warning, foo: unknown field with tag 42113 (0xa481) encountered.
foo: Sorry, can not handle images with 32-bit samples.
QPixmap::scaled: Pixmap is a null pixmap
这是我目前正在尝试的:
QString s1 = QFileDialog::getOpenFileName(this, "Open a DSM", "/home", "Images (*.png *.xpm *.jpg *.tif *.tiff)");
ui->DSMPath->setText(s1);
QPixmap dispdsm(s1);
int w = ui->DSMDisplay->width();
int h = ui->DSMDisplay->height();
ui->DSMDisplay->setPixmap(dispdsm.scaled(w,h,Qt::KeepAspectRatio));
在网上搜索了一下,好像还没有解决办法
我明确表示我正在 Ubuntu 使用 QT 和 OpenCV 以及 Magick++ 库。
有人可以帮助我吗? 非常感谢:)
Qt 根本不支持您正在使用的格式的图像。您需要为 libgeotiff 使用自己的 QImageIOHandler
包装器。
Kuba Ober 是对的,但是对于那些想要显示 geotiff 图像而不定义自己的 QImageIOHandler
和使用 OpenCV 的人,您可以将 geotiff 图像作为 OpenCV 矩阵加载并将其转换为 QImage .
这里是我的转换:
QImage image= QImage((uchar*) dsm.data, dsm.cols, dsm.rows, dsm.step, QImage::Format_ARGB32_Premultiplied);
QPixmap dispdsm = QPixmap::fromImage(image);
其中 dsm
在我的 OpenCV 矩阵中,dispdsm
它的可显示版本。