Using system.drawing; using system.componentmodel; using system.windows.form; using system.data;
A summary description of Namespace SmaillPic {///
Public Form1 () {// // Windows Form Designer Support for // InitializeComponent ();
// // Todo: Add any constructor code after INITIALIZEComponent call //}
private void InitializeComponent () {System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof (Form1)); this.pictureBox1 = new System.Windows.Forms.PictureBox (); this.textBox1 = new System.Windows. Forms.TextBox (); this.button1 = new system.windows.Forms.Button (); this.openfiledialog1 = new system.windows.Forms.openFiledialog (); this.suspendlayout (); // // PictureBox1 // THIS .PICTUREBOX1.Image = ((System.drawing.Image)) ("PictureBox1.image")); this.picturebox1.location = new system.drawing.point (16, 8); this.PictureBox1.name = "PictureBox1"; this.picturebox1.size = new system.drawing.size (272, 216); this.picturebox1.tabindex = 0; this.picturebox1.tabstop = false; /// textbox1 // this.TextBox1. Location = new system.drawing.point (0, 240); this.TextBox1.name = "textbox1"; this.textBox1.size = new system.drawing.size (168, 21); this.TextBox1.tabindex = 1; THIS.TEXTBOX1.TEXT = ""; // // Button1 // this.button1.location = new system.drawing.point (208, 240); this.button1.name = "button1"; this.button1.tabindex = 2; this.button1.text = "Select"; .Button1.click = new system.eventhandler (this.button1_click); /// // form1 // this.autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size 292, 273); this.controls.add (this.button1); this.Controls.add (this.textBox1); this.controls.add (this.PictureBox1); this.name = "form1"; this.ResumeLayout False);
public void SmallPic (string strOldPic, string strNewPic, int intWidth, int intHeight) {//System.Drawing.Bitmap sdb; try {objPic = new System.Drawing.Bitmap (strOldPic); objNewPic = new System.Drawing.Bitmap (objPic , intWidth, INTHEIGHT; ObjneWPIC.SAVE (STRNEWPIC);} catCH (Exception Exp) {throw exp;} // finally // {// ObjPic = null; // ObjnewPic = null; //}}
private void button1_Click (object sender, System.EventArgs e) {OpenFileDialog fd = new OpenFileDialog (); if (fd.ShowDialog () == DialogResult.OK) {this.textBox1.Text = fd.FileName;} this.SmallPic ( FD.FileName, "1111.bmp", 200, 200); this.picturebox1.image = (image) this.objnewPic;} ///
///
///
//System.Drawing.Bitmap objPic, objNewPic; try {objPic = new System.Drawing.Bitmap (strOldPic); int intHeight = (intWidth / objPic.Width) * objPic.Height; objNewPic = new System.Drawing.Bitmap (objPic , intWidth, INTHEIGHT; ObjnewPic.save (STRNEWPIC);
} Catch (Exception exp) {throw exp;} finally {objPic = null; objNewPic = null;}} public void SmallPicOnHeight (string strOldPic, string strNewPic, int intHeight) {try {objPic = new System.Drawing.Bitmap (strOldPic) ; int intWidth = (intHeight / objPic.Height) * objPic.Width; objNewPic = new System.Drawing.Bitmap (objPic, intWidth, intHeight); objNewPic.Save (strNewPic);} catch (Exception exp) {throw exp;} // finally // {// objPic = null; // ObjnewPic = null; //}}
}