⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rotation01.aspx.cs

📁 用asp.net c#关于网页的图片旋转,放大,缩小.
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;


namespace SkillGather.Web
{
	/// <summary>
	/// Rotation01 的摘要说明。
	/// </summary>
	public class Rotation01 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button BtnRotate;
		

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
//			for (int i=0;i<5;i++)
//			{
////				ImageButton[] Ibtn[i]=new ImageButton; 
//			}
		



		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.BtnRotate.Click += new System.EventHandler(this.BtnRotate_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void BtnRotate_Click(object sender, System.EventArgs e)
		{
			string strFilename;
			System.Drawing.Image TImage;

			strFilename=Server.MapPath("./image/00000318_0057_006660.jpg");
			TImage=System.Drawing.Image.FromFile(strFilename);

			Bitmap b=new System.Drawing.Bitmap(TImage.Width,TImage.Height,PixelFormat.Format24bppRgb);
			Graphics g=Graphics.FromImage(b);
			//g.Clear(Color.Blue);
			//旋转图片
//			TImage.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipNone);//原模样
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);//顺时针转90度
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);//顺时针180度
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone);//顺时针270度

//			TImage.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);//左右反转
			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipX);//水平翻转180
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);//上下反转
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipXY);
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipY);//垂直翻转180
//			
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipX);
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipXY);
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipY);

			g.DrawImage(TImage,new Point(0,0));
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipY);
//			
//			g.RotateTransform(10);
//			g.DrawImage(TImage,new Point(0,0));
//			g.RotateTransform(10);
//			g.DrawImage(TImage,new Point(20,20));
//			g.RotateTransform(10);
//			g.DrawImage(TImage,new Point(40,40));
//			g.RotateTransform(10);
//			g.DrawImage(TImage,new Point(40,40));
//			g.RotateTransform(-40);
//			g.RotateTransform(90);
//			g.DrawImage(TImage,new Rectangle(100,-360,100,50),new Rectangle(20,20,TImage.Width-20,TImage.Height -20),GraphicsUnit.Pixel);
//			g.RotateTransform(-90);
//
//			//拉伸图片
//			g.DrawImage(TImage,new Rectangle(10,10,50,50),new Rectangle(20,20,TImage.Width -20,TImage.Height-20),GraphicsUnit.Pixel);
//			g.DrawImage(TImage,new Rectangle(50,10,90,50),new Rectangle(20,20,TImage.Width -20,TImage.Height-20),GraphicsUnit.Pixel);
//			g.DrawImage(TImage,new Rectangle(110,10,150,50),new Rectangle(20,20,TImage.Width -20,TImage.Height-20),GraphicsUnit.Pixel);
//
//			//切割图片
//			g.DrawImage(TImage,50,100,new Rectangle(180,80,60,110),GraphicsUnit.Pixel);
//			g.DrawImage(TImage,140,100,new Rectangle(180,80,60,110),GraphicsUnit.Pixel);

			//旋转图片
//			TImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
//			g.DrawImage(TImage,230,100,new Rectangle(180,110,60,110),GraphicsUnit.Pixel);

//			g.DrawImage(TImage,0,0,new Rectangle(0,0,400,400),GraphicsUnit.Pixel);

			Response.ContentType="image/jpeg";
			b.Save(Response.OutputStream,ImageFormat.Jpeg);
			b.Dispose();
			
		
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -