图像查看器 - 标准gui控件,自下而上或什么? [英] Image viewer - standard gui controls, bottom-up or what?

查看:161
本文介绍了图像查看器 - 标准gui控件,自下而上或什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要制作基本图像查看器
主要关注的是如何实现(在gui组件和图像处理方面)诸如放大,滚动和'手工工具'等功能。

I need to make a basic image viewer. The main concern is how to implement (in terms of gui components and image manipulation) such features as: zoom in-out, scroll and 'hand tool'.

实现这一目标似乎有几种选择,主要是在图形界面框架上放置责任的程度,而不是手动实现。

There seems to be several options for achieving this goal, differing mainly in degree of putting responsibilities on the graphical interface framework as opposed to manually implementing things.

两个解决方案对我来说很明显:

Two solutions that are obvious to me are:

1)使用某些图像处理功能自行设计图像的可见部分的大小和裁剪图书馆。然后在重写的 onPaint()方法中的某个窗口/控件上绘制图像(或其部分)。需要编写滚动条更新(使用'手工工具'时)和操作(直接使用时)代码。

1) Resizing and cropping the visible part of the image is crafted on its own using functionality of some image manipulation library. The image (or it's part) is then drawn on some window/control in an overridden onPaint() method. Scrollbars updating (when 'hand tool' used) and operation (when used directly) code needs to be written.

2)包含图像的超大控件(StaticBitmap或其他)放在一个自动滚动的窗口中。然后需要弄清楚如何将图像坐标转换为滚动坐标。

2) An oversized control (StaticBitmap or whatever) containing the image is put inside a window with automatic scrolling. Then one needs to figure out how to convert image coordinates to scrolling coordinates.

两种方式看起来都很尴尬。任何想法如何在整洁的方式?或者我认为只是唯一的方式是丑陋的?

Both ways look awkward. Any ideas how to do it in a neat way? Or is what I feel as being ugly just the only way to go?

我正在使用Python与wxPython / wxWidgets和PIL,但问题在很大程度上语言和平台无关。

I'm using Python with wxPython/wxWidgets and PIL, but the question is to a large extent language- and platform- independent.

欢迎使用示例代码和源代码链接(不太臃肿的东西)。

Sample code and links to sources (of something that is not too bloated) are welcome.

推荐答案

这是一个可能有用的教程。 构建wxPython图像查看器

Here's a tutorial that might help. Build a wxPython Image Viewer

我实际上并没有看过所有的视频,所以我不能说出它解决你的具体问题的程度。

I didn't actually watch all the videos, so I can't speak to how well it address's your specific problems.

此外,这是Jeff Atwood的博客文章关于可能适用的编码恐怖。 编程很难,我们去购物吧!这说明你何时应该花时间编写自己的代码以及何时只使用第三方解决方案。

Also, here's a blog post by Jeff Atwood on Coding Horror that could apply. Programming Is Hard, Let's Go Shopping! It speaks to when you should take the time to write your own code and when to just use a third party solution.

这篇关于图像查看器 - 标准gui控件,自下而上或什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆