“Python.exe” 当使用 Pixmap 调用 PyQt 的 setPixmap() 时崩溃

发布于 2024-07-25 08:57:07 字数 572 浏览 3 评论 0原文

我有一个程序,可以使用套接字相互发送和接收图像。 服务器使用'image.tostring()'发送图像数据,客户端接收它并使用'Image.fromstring'将其转换回图像,然后使用'ImageQt.ImageQt(image)'将其转换为QImage,将其转换使用“QPixmap.fromimage(qimage)”进入 QPixmap,然后使用“lable.setPixmap(qpixmap)”更新我的 QWidget 的 QLable 图像

对于小图像,一切正常,但对于大于 200x200 的图像,python.exe 崩溃,控制台仅显示“进程终止,退出代码为-1073741819”,并且没有告诉我问题是什么。

我已将问题隔离到“setPixmap()”(只要我注释掉,其他所有内容都有效),但我看不出问题是什么。

这仅发生在客户端。 服务器端使用相同的步骤从 Image 到 QImage 到 QPixmap 然后 setPixmap,但这没有任何问题。

还尝试将其设为 QBitmap 并在位图上使用 setPixmap,这有效(但它是黑白的,因此无法使用它)。 诡异的!

任何帮助,将不胜感激!

I have a program that sends and receives images to each other using sockets.
The server sends the image data using 'image.tostring()' and the client side receives it and turns it back into an image using 'Image.fromstring', then into a QImage using 'ImageQt.ImageQt(image)', turns it into a QPixmap using 'QPixmap.fromimage(qimage)'then updates my QWidget's QLable's image using 'lable.setPixmap(qpixmap)'

Everything works fine with small images, but with images larger than 200x200, python.exe crashes and the console only shows "Process terminated with an exit code of -1073741819" and doesn't tell me what the problem is.

I've isolated the problem down to 'setPixmap()' (everything else works as long as I comment out that), but I can't see what the problem is.

This only happens on the client side. The server side uses the same steps going from Image to QImage to QPixmap then setPixmap, but that doesn't have any problems.

Also tried making it a QBitmap and using setPixmap on the bitmap, which worked (but it's black and white so can't use it). Weird!

Any help would be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼痛 2024-08-01 08:57:07

可能值得将图像数据转储到文件中,并通过将其加载到图像查看器中来检查是否拥有所有数据。 如果你得到的数据不完整,你也许仍然能够获取一个QImage并创建一个QPixmap,但是它可能是无效的。

It may be worth dumping the image data to a file and checking that you have all the data by loading it into an image viewer. If you get incomplete data, you may still be able to obtain a QImage and create a QPixmap, but it may be invalid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文