如题,求pictureBox放大缩小功能,最好能找到示例代码,谢了
解决方案 »
- DataList跟GridView区别在哪里?
- 一个窗体占用资源的问题。
- excel导入数据库遇到的问题
- 这里的例子不理解,希望有详细解答
- listview的问题
- wpf 窗体中的用户控件,如何调用窗体中的其他控件?
- <<<怎样把ListView中的一行置为选中状态>>>
- 如何禁用窗体的关闭按钮(右上角那个),而保留最小化和最大化?(C#)
- vc++.net和C#那个功能强大些?
- 如何将double转为DateTime?
- WPF:如何在Canvas中添加控件?
- 在 System.Data.SqlClient.SqlException 中第一次偶然出现的“System.Data.dll”类型的异常
/// 放大图形
/// </summary>
/// <param name="p_Bitmap">图形</param>
/// <param name="p_Width">放大后的宽</param>
/// <param name="p_Height">放大后高</param>
/// <param name="p_ZoomType">放大类型 true为插值</param>
/// <returns>放大后的图形</returns>
public static Image BitmapToBlowUp(Image p_Bitmap, int p_Width, int p_Height, bool p_ZoomType)
{
Bitmap _ZoomBitmap = new Bitmap(p_Width, p_Height); Graphics _Graphics = Graphics.FromImage(_ZoomBitmap); if (!p_ZoomType)
{
_Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
_Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
} _Graphics.DrawImage(p_Bitmap, 0, 0, _ZoomBitmap.Width, _ZoomBitmap.Height);
_Graphics.Dispose();
return _ZoomBitmap;
}
很简单
//对图片进行放大缩小操作
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
//string width = pictureBox1.Width.ToString();
if (e.Button == MouseButtons.Left)
{
if (pictureBox1.Width < 1360)
{
pictureBox1.Width = Convert.ToInt32(pictureBox1.Width * 1.2);
pictureBox1.Height = Convert.ToInt32(pictureBox1.Height * 1.2);
}
}
if (e.Button == MouseButtons.Right)
{
if (pictureBox1.Width > 635)
{
pictureBox1.Width = Convert.ToInt32(pictureBox1.Width / 1.2);
pictureBox1.Height = Convert.ToInt32(pictureBox1.Height / 1.2);
}
}
}