如何使用 wxPython 裁剪图像?
我想通过使用两点坐标或一个点和大小从 wxImage 中提取子图像。
我假设 Resize()
本来应该这样做,但看起来它没有给出预期的结果。
例如,执行 Resize(Size(10,10),Point(0,0)) 会给我正确的结果左上角 10x10 子图像。
现在,如果我想得到其他东西,我就会迷失在二维空间中;)
I want to extract a subimage from a wxImage by using the two-point coordinates or one point and the size.
I assumed that Resize()
was supposed to do that, but it looks that it doesn't give the desired results.
For example doing Resize(Size(10,10),Point(0,0)) will give me the right results top-left 10x10 subimage.
Now if I want to get something else I'm kinda lost in two-dimensional space ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎
Resize()
的工作方式没有得到很好的解释:p这是裁剪解决方案:
cropped = WxImage.GetSubImage(rect)
It seems that
Resize()
works in ways that are not well explained :pHere is the crop solution:
cropped = WxImage.GetSubImage(rect)
我认为你不能以这种方式使用 wxPython。但是您可以获取所获得的信息并使用 Python 成像库来执行您想要的操作: http: //www.pythonware.com/products/pil/ 它支持裁剪以及许多其他图像处理技术。
I don't think you can use wxPython in that way. But you could take the information you're getting and use the Python Imaging Library to do what you want: http://www.pythonware.com/products/pil/ It supports cropping along with many other image manipulation techniques.