C#PictureBox缩放模式效果与图形对象 [英] C# PictureBox Zoom Mode Effect With Graphics Object

查看:559
本文介绍了C#PictureBox缩放模式效果与图形对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图片框可以选择属性中的图片模式,其中一种模式是缩放模式,如何使用图形对象实现相同的缩放模式效果?



问候,

Jordan

Picture boxes have the option to choose the picture mode in the properties, one of these modes is zoom mode, how do I achieve that same zoom mode effect with a graphics object?

Regards,
Jordan

推荐答案

即使只进行缩放,或者除了显示静态图片之外的任何其他内容code> PictureBox ,这是一个明确的指标,你应该抛弃这个几乎毫无意义的控制并自己渲染图形,这会容易得多。在这种情况下,可以使用 PictureBox ,但它只会耗费你的开发时间和一些额外的资源而不给予任何回报。



请查看我过去的答案:

在图片框中附加图片 [ ^ ],

在C#中绘制一个矩形 [ ^ ],

如何从旧图纸中清除面板 [ ^ ]。



我在过去的回答中特别说明了缩放:在C#.net鼠标滚轮中缩放图像 [ ^ ]。



请参阅以下 System.Windows.Forms 中呈现的过去答案:

捕捉面板上的图纸 [ ^ ],

什么样的俏皮方法是Paint? (DataGridViewImageCell.Paint(...)) [ ^ ],

mdi子表单之间的绘制线 [ ^ ],

如何加速我的vb.net应用程序? [ ^ ]。







如果您需要知道如何重新采样位图(请参阅下面的评论),请参阅其他过去的答案:

在vb.net中查看图片 [ ^ ],

在流中读取Big Tiff和JPEG文件(>(23000 x 23000)pix)。并实时显示部分内容。 [ ^ ]。



-SA
Even if you do just the zoom, or anything else beyond showing static picture in PictureBox, this is a clear indicator that you should throw off this nearly pointless control and render graphics by yourself, which would be much easier. In such cases, PictureBox could be used, but it will only eat up your development time and some extra resources giving nothing in return.

Please see my past answers:
Append a picture within picturebox[^],
draw a rectangle in C#[^],
How do I clear a panel from old drawing[^].

I explained zoom specifically in my past answer: Zoom image in C# .net mouse wheel[^].

See also these past answers on rendering in System.Windows.Forms:
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
Drawing Lines between mdi child forms[^],
How to speed up my vb.net application?[^].



If you need to know how to re-sample a bitmap (please see my comment below), please see other past answers:
resize image in vb.net[^],
Read Big Tiff and JPEG files (>(23000 x 23000) pix) in a stream. And display part of it to the screen in realtime.[^].

—SA


有成千上万的使用PictureBox控件的.NET程序员,并且 nothing 错误。与使用旧版GDI +图形引擎的WinForms相比,WPF为矢量或位图的干净缩放提供了更多功能。



如果你正在使用动画Gif文件,任意缩放它可能会有问题,而且,无论你使用什么.NET工具,你都必须在扩展时处理保持纵横比。



使用带有WinForms GDI +图形引擎的Gif文件存在一些特殊问题,任何强大的重新调整大小都需要您处理图像颜色量化和调色板。请参阅此处的讨论:[ ^ ]。



这些资源可能对您有所帮助:[ ^ ],[ ^ ]。



非常有用的图像调整大小的C#代码:[ ^ ]。
There are hundreds of thousands of .NET programmers that use the PictureBox Control, and there is nothing wrong with it. WPF offers much more functionality for "clean" scaling of vectors, or bitmaps, than WinForms which uses the older GDI+ graphics engine.

If you are working with an animated Gif file, scaling it arbitrarily is probably going to be problematic, and, whatever .NET facility you use, you'll have to deal with maintaining aspect ratio as you scale.

There are some special problems using Gif files with the WinForms GDI+ graphics engine, and any robust re-sizing is going to require you deal with image color quantization and color palette. See the discussion here: [^].

These resources may prove helpful to you: [^], [^].

Very useful C# code for image resize here: [^].


这篇关于C#PictureBox缩放模式效果与图形对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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