缩放图片框内的图像
我有一个图片框控件和 2 个命令按钮。我在图片框中显示了一张图像。
单击“放大”和“缩小”按钮时是否可以缩放图像?
或者我什至可以放一个滚动条。是否可以根据滚动条的移动来缩放图像?
我用的是VB 6。
I'm have a picture box control and 2 Command Buttons. I have an image displayed inside the picture box.
Is it possible to zoom the image when the Zoom-in and Zoom out buttons are clicked?
Or I can even put a scroll bar. Is it possible to zoom the image according to the scroll bar movements?
I'm using VB 6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您在这里使用 BMP 或 JPG 文件。
简单的临时方法是在 PictureBox 中放置一个 Image 控件,最初使用属性 Stretch = False。最初,它位于左上角。将 Picture 属性设置为图片对象后,Image 控件将调整大小以适合图像。将控件的原始宽度和高度保存在变量中。现在设置 Stretch = True。 调整图像大小来放大图像。
您可以通过使用Where sngMaxFactor = 4! 或者您想要放大多少。
通过以下方式恢复到原始大小:
您还可以通过更改 Move() 方法中的 Left 和 Top 参数来平移缩放的图像。
I assume here that you are using BMP or JPG files here.
The simple scratch method is to place an Image control in the PictureBox, initially with the property Stretch = False. Initially, it would be in the top left hand corner. After setting the Picture property to your picture object, the Image control will be resized to fit the image. Save the original width and height of the control in variables. Now set Stretch = True. You can zoom in by resizing the image using
Where sngMaxFactor = 4! or however much you want to zoom by.
Restore back to original size by:
You can also pan the zoomed image by altering the Left and Top arguments in the Move() method.
使用两个图片框可能是最简单的,一个在另一个里面。 “外部”框可以被视为“内部”框的视口,您可以根据需要调整其大小和位置。效果是一样的,但是编码要简单得多。
It might be easiest to use two pic boxes, one inside the other. The 'outer' box can be thought of as a viewport into the 'inner' box, which you resize and position as needed. The effect will be the same but the coding is much simpler.