如何放大和放大器;出在C#中的图像 [英] How to zoom in&out an image in c#
本文介绍了如何放大和放大器;出在C#中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编写一个程序,将实施变焦和C#缩小任务。我不想调整图片框,我想调整画面的本身。但我不知道我该怎么做确切。 ?你能帮
I want to write a program that will implement the zoom in and zoom out task in c#. I dont want to resize pictureBox, I want to resize picture's itself. But I dont know what i'm gonna do exactly. Can you help?
推荐答案
解决方案之一是:
- 创建所需的大小(例如200%的原始图像尺寸的50%)
- 的新形象使用的Graphics.DrawImage(Image,矩形); ,给定图像在给定位置给定尺寸绘制的新形象
- 设置新的图像源的
图片框
- Create new image of the desired size (for example 200% or 50% of original image size)
- Draw original image to new image using Graphics.DrawImage(Image, Rectangle);, which draws the given image to the new image at the given position with the given size
- Set new image as source for the
PictureBox
另一种方法是简单的创建一个这样的新的位图的实例:
Another way is to simple create a new bitmap instance like that:
Size newSize = new Size((int)(originalBitmap.Width * zoomFactor), (int)(originalBitmap.Height * zoomFactor));
Bitmap bmp = new Bitmap(originalBitmap, newSize);
这篇关于如何放大和放大器;出在C#中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文