C#中:简单而实用的方法来放大与滚动​​条图片框图片 [英] C#: Simple and functional way to zoom picturebox images with scroll bars

查看:342
本文介绍了C#中:简单而实用的方法来放大与滚动​​条图片框图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个简单而实用的方法来放大,包括滚动条的图片框的图像?

Is there a simple and functional way to zoom an image in a picturebox including scroll bars?

目前,我在汽车面板使用图片框滚动激活。要放大,我放大图片框,并在面板上的滚动条移动。问题是,它的行为很奇怪。例如:如果你放大到远,上,左边框形式和图像获取的越做越大之间的空白。

At the moment, I use a picture box in a panel with auto scroll activated. To zoom, I enlarge the picturebox and move it with the scroll bars on the panel. The problem is, that it behaves strange. For example: If you zoom in to far, the margin between the upper and left form border and the image get's bigger and bigger.

这就是缩放方法。我从这里 得到了它。

That's the zooming method. I got it from here.

private void ZoomInOut(bool zoom)
    {
        //Zoom ratio by which the images will be zoomed by default
        int zoomRatio = 10;
        //Set the zoomed width and height
        int widthZoom = pictureBox_viewer.Width * zoomRatio / 100;
        int heightZoom = pictureBox_viewer.Height * zoomRatio / 100;
        //zoom = true --> zoom in
        //zoom = false --> zoom out
        if (!zoom)
        {
            widthZoom *= -1;
            heightZoom *= -1;
        }
        //Add the width and height to the picture box dimensions
        pictureBox_viewer.Width += widthZoom;
        pictureBox_viewer.Height += heightZoom;

    }



任何帮助表示赞赏。

Any help is appreciated.

在此先感谢

马可波罗

编辑:
的未缩放和放大(16倍)图像的两个屏幕截图。
注重于图像的上边界和形式的上缘之间的空白。

Two screenshots of an unzoomed and a zoomed (16 times) image. Pay attention to the margin between the upper border of the image and the upper border of the form.

推荐答案

我认为它能够更好地放大(重新调整)的形象,而不是图片框。看看这篇文章 -
http://www.codeproject.com/文章/ 21097 / PictureBox的变焦

I think its better to zoom(rescale) the image and not the picture box. Take a look at this article - http://www.codeproject.com/Articles/21097/PictureBox-Zoom

How放大和放大器;出图像中的C#

这篇关于C#中:简单而实用的方法来放大与滚动​​条图片框图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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