Visual Programming: Fatima Jinnah Women University, Rawalpindi
Visual Programming: Fatima Jinnah Women University, Rawalpindi
INTRODUCTION
Paint (formerly Paintbrush for Windows) is a simple graphics painting program that has been included with all versions of Microsoft Windows. It is often referred to as MS Paint or Microsoft Paint. Paint can use to create drawings on a blank drawing area or in existing pictures. MAIN INTERFACE: Main interface of paint application:
BACKGROUND COLOR: Opening color dialogue box for choosing background color:
The background color being chosen is as well applied to the background color in main menu bar. `
Free hand drawing can be done. By default 2 is the size, it can be changed by the user as required.
PUTTING TEXT: Text can be put in the text box in main menu bar. After that choose font size and color for text. On click text will be put on the canvas(panel).
PAINT BRUSH:
User can select any color and size of paint brush.
SHAPES: In main menu bar different shapes are mentioned including circle, rectangle, square, polygon and line. User can select size and color for any shape. On click the shape with selected color is drawn. Three types of shapes are there in menu for shapes that are filled, hollow and linear gradient. For linear gradient choose one color from color1 and second from color2 dialogue box.
On main menu bar there is a short cut for opening new page. Clicking on it opens a new page as shown in the picture.
OPEN DIALOUGE BOX FOR OPENING ANY EXISTING FILE/PICTURE: Clicking on the open dialogue box short cut in main menu bar opens the block as shown. From here any already existing file can be opened.
DRAWING ON IMPORTED IMAGE: Drawing can be done on imported picture. User can use pen, brush, shapes and eraser on the imported picture.
ZOOM: Clicking on zoom button in main menu bar opens a new window. The point under cursor is zoomed. Zooming is applied on cursor movement. User can select size for zoom by putting required zoom size in size option in zoom window.
ERASER: Eraser can be used to erase anything as required after selecting eraser from menu bar.
DROP DOWN MENU FOR OPEN, NEW, SAVE AND EXIT: Clicking on the paint button opens the drop down option for opening new page or any existing picture, save option and exit. Shortcuts for all these option are also there as explained earlier.
CLEAR ALL: Clicking on the clear all button at the top clears every thing from the canvas.
SAVE AS: On clicking save as option open the following box. User can select the directory as wish and can save the canvas as jpeg and .png image with any name.
EXIT THE APPLICATION: User can exit the application by clicking on the exit option in drop down main ,menu.
IMAGE PROCESSING: On clicking the image processing option in main menu open the new window. User can select any picture from directory. Drag and drop option is also available.
BRIGHTNESS: The brightness of the selected image can be increased or decreased form the track bar for brightness at the bottom. At the end of track bar the digit change and shows how much brightness is increased.
ROTATING THE IMAGE: The imported image can be rotated. On clicking the rotate button a drop down menu is opened giving four options or rotation angles. a) rotating right b) rotating left c) rotating vertical d) rotating horizontal
CROPPING: Import an image. Click on the crop selection to select the area for cropping. After that click on the crop button.
On clicking the crop button the cropped picture will be displayed on the canvas.
GREY SCALE: User can convert the image in grey scale by clicking on the grey scale button.
INVERT: The picture can be converted into negative on clicking the invert button.
RESIZING: The imported image or picture can be resized. User can increase or decrease the size of image from the combo box at right side in percentages. Clicking on OK button implements the selected size. The original and resized size is also mentioned.
ZOOM THE IMAGE: On clicking on zoom button new zoom window is opened. Size can be set by the user. Zoom is implemented with cursor movement.
SAVE THE PROCESSED IMAGE: The processed image can be saved as jpeg or .png with any name by selecting the directory.
PRINT FORM:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Drawing.Imaging; namespace repaint_application { public partial class Paint : Form { public Paint() { InitializeComponent(); g = panel2.CreateGraphics(); toolStripComboBox2.Items.Add(20); toolStripComboBox2.Items.Add(50); toolStripComboBox2.Items.Add(80); toolStripComboBox2.Items.Add(100); toolStripComboBox2.Items.Add(120); toolStripComboBox2.Items.Add(150); toolStripComboBox2.Items.Add(180); toolStripComboBox2.Items.Add(200); } return myCursor; public Cursor CreateCursor(Image image) { //Get the Bitmap form of the Image Bitmap bitmap = new Bitmap(image); //Have the Graphics Work from the Bitmap Graphics graphics = Graphics.FromImage(bitmap); //Get the Icon Handle IntPtr handle = bitmap.GetHicon(); //Create the new Cursor Cursor myCursor = new Cursor(handle); //Return the cursor } public int OldX; public int OldY;
Graphics g; private void panel2_Paint(object sender, PaintEventArgs e) { } private void Paint_Load(object sender, EventArgs e) { toolStripTextBox1.Text = "2"; } int? prevx = null; int? prevy = null; private void panel2_MouseMove(object sender, MouseEventArgs e) { if (canpaint) { dd = false; brush = false; penpaint = false; Pen p = new Pen(toolStripButton8.ForeColor, float.Parse(toolStripTextBox1.Text)); g.DrawLine(p,new Point(prevx?? e.X,prevy?? e.Y),new Point(e.X,e.Y)); prevx=e.X; prevy=e.Y; } else if (dd) { Pen myPen = new Pen(toolStripButton9.ForeColor, float.Parse(toolStripTextBox1.Text)); g.DrawLine(myPen, OldX, OldY, e.X, e.Y); OldX = e.X; OldY = e.Y; this.Cursor = CreateCursor(Image.FromFile(@"C:\Users\YASAR\Desktop\49px-Eraser.gif")); } else if (brush) { dd = false; canpaint = false; penpaint = false; SolidBrush a = new SolidBrush(toolStripButton8.ForeColor); g.FillEllipse(a, e.X, e.Y, Convert.ToInt32(toolStripTextBox1.Text), Convert.ToInt32(toolStripTextBox1.Text)); } else if (penpaint) { brush = false; canpaint = false; Pen p = new Pen(toolStripButton8.ForeColor, float.Parse(toolStripTextBox1.Text)); g.DrawLine(p, new Point(prevx ?? e.X, prevy ?? e.Y), new Point(e.X, e.Y)); prevx = e.X; prevy = e.Y; dd = false; } } private void panel2_MouseUp(object sender, MouseEventArgs e) { canpaint = false; dd = false;
brush = false; prevx = null; prevy = null; } bool canpaint = false; private void panel2_MouseDown(object sender, MouseEventArgs e) { canpaint = true; dd = false; brush = true; penpaint = true; if (filledRectangular) { SolidBrush s = new SolidBrush(toolStripButton8.ForeColor); g.FillRectangle(s, e.X, e.Y, 2*Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); canpaint = false; filledRectangular = false; dd = false; } else if (hollowrec) { Pen f = new Pen(toolStripButton8.ForeColor); g.DrawRectangle(f, e.X, e.Y, 2*Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); canpaint = false; penpaint = false; brush = false; hollowrec = false; dd = false; } else if (filledsqare) { SolidBrush w = new SolidBrush(toolStripButton8.ForeColor); g.FillRectangle(w, e.X, e.Y, Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); canpaint = false; penpaint = false; brush = false; filledsqare = false; dd = false; } else if (circle) { SolidBrush q = new SolidBrush(toolStripButton8.ForeColor); g.FillEllipse(q, e.X, e.Y, Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); circle = false; canpaint = false; penpaint = false; brush = false; filledRectangular = false; dd = false; } else if (holcircle) { Pen z = new Pen(toolStripButton8.ForeColor); g.DrawEllipse(z, e.X, e.Y, Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); holcircle =false;
canpaint = false; penpaint = false; brush = false; dd = false; } else if (fpoly) { SolidBrush b = new SolidBrush(toolStripButton8.ForeColor); Point[] points = { new Point(50, 50), new Point(0, 50), new Point(50, 20), new Point(20, 50) }; g.FillPolygon(b,points); fpoly = false; dd = false; } else if (rr) { Pen f = new Pen(toolStripButton8.ForeColor); g.DrawRectangle(f, e.X, e.Y, Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); canpaint = false; penpaint = false; brush = false; rr = false; } else if (lin) { LinearGradientBrush b = new LinearGradientBrush(new Point(e.X, e.Y), new Point(e.X, 2 * e.Y), (toolStripButton8.ForeColor), (toolStripButton5.ForeColor)); g.FillRectangle(b, e.X, e.Y,2* Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); lin = false; dd = false; } else if (lc) { LinearGradientBrush w = new LinearGradientBrush(new Point(e.X, e.Y), new Point(e.X, 2 * e.Y), (toolStripButton8.ForeColor), (toolStripButton5.ForeColor)); g.FillEllipse(w, e.X, 2*e.Y, Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); lc = false; dd = false; } else if (sg) { LinearGradientBrush t = new LinearGradientBrush(new Point(e.X, e.Y), new Point(e.X, 2 * e.Y), (toolStripButton8.ForeColor), (toolStripButton5.ForeColor)); g.FillRectangle(t, e.X, 2 * e.Y, Convert.ToInt32(toolStripComboBox2.SelectedItem), Convert.ToInt32(toolStripComboBox2.SelectedItem)); sg = false; dd = false; } } private void toolStripComboBox1_Click(object sender, EventArgs e) { } private void toolStripTextBox1_Click(object sender, EventArgs e) { toolStripTextBox1.Text = "2"; } private void toolStripButton8_Click(object sender, EventArgs e) {
ColorDialog cd = new ColorDialog(); if (cd.ShowDialog() == DialogResult.OK) { toolStripButton8.ForeColor = cd.Color; } } private void toolStripButton1_Click(object sender, EventArgs e) { g.Clear(Color.White); } private void toolStripButton9_Click(object sender, EventArgs e) { ColorDialog cd = new ColorDialog(); if (cd.ShowDialog() == DialogResult.OK) { toolStripButton9.ForeColor = cd.Color; } panel2.BackColor = cd.Color; } bool filledRectangular = false; private void filledRectangularToolStripMenuItem_Click(object sender, EventArgs e) { filledRectangular = true; } bool hollowrec = false; private void hollowRectangularToolStripMenuItem_Click(object sender, EventArgs e) { hollowrec = true; } private void panel2_DragDrop(object sender, DragEventArgs e) { string[] imagepath = (string[]) e.Data.GetData(DataFormats.FileDrop); foreach (string path in imagepath) { g.DrawImage(Image.FromFile(path), new Point(0, 0)); } } private void panel2_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.All; } bool brush = false; private void toolStripButton4_Click(object sender, EventArgs e) { brush = true; canpaint = false; penpaint = false; } bool filledsqare = false; private void filledSqareToolStripMenuItem_Click(object sender, EventArgs e) { filledsqare = true; } bool circle = false; private void filledCircleToolStripMenuItem_Click(object sender, EventArgs e) { circle = true; } bool holcircle = false; private void hollowCircleToolStripMenuItem_Click(object sender, EventArgs e) {
holcircle = true; } bool penpaint = false; private void toolStripButton3_Click(object sender, EventArgs e) { penpaint = true; } private void toolStripLabel5_Click(object sender, EventArgs e) { } bool fpoly = false; private void filledPolygonToolStripMenuItem_Click(object sender, EventArgs e) { fpoly = true; canpaint = false; brush = false; penpaint = false; } private void panel2_MouseClick(object sender, MouseEventArgs e) { canpaint = false; penpaint = false; brush = false; if (line) { canpaint = false; Pen o = new Pen(toolStripButton8.ForeColor); g.DrawLine(o, new Point(0,0), new Point(100, 200)); } else if (text) { SolidBrush d = new SolidBrush(toolStripButton8.ForeColor); FontFamily ff = new FontFamily("Arial"); System.Drawing.Font f = new System.Drawing.Font(ff,float.Parse((toolStripTextBox1.Text))); g.DrawString(toolStripTextBox2.Text, f, d, new PointF(e.X, e.Y)); text = false; } } bool line = false; private void toolStripButton15_Click(object sender, EventArgs e) { line = true; } bool text = false; private void toolStripButton2_Click(object sender, EventArgs e) { text = true; canpaint = false; penpaint = false; brush = false; } private void openToolStripButton1_Click(object sender, EventArgs e) { OpenFileDialog n = new OpenFileDialog(); n.ShowDialog(); string path = n.FileName; g.DrawImage(Image.FromFile(path), new Point(0, 0));
} static public Panel p = new Panel(); private void saveToolStripButton2_Click(object sender, EventArgs e) { SaveFileDialog s = new SaveFileDialog(); s.DefaultExt = "Jpeg"; s.Filter = "Jpeg files|*.jpg"; if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int width = panel2.Width; int height = panel2.Height; Bitmap bitMap = new Bitmap(panel2.Width, panel2.Height); panel2.DrawToBitmap(bitMap, new Rectangle(0, 0, panel2.Width, panel2.Height)); bitMap.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); } } private void toolStripButton14_Click(object sender, EventArgs e) { zoom z = new zoom(); z.Show(); } private void toolStripLabel8_Click(object sender, EventArgs e) { ImageProcessing q = new ImageProcessing(); q.Show(); } bool rr = false; private void hollowSqareToolStripMenuItem_Click(object sender, EventArgs e) { rr = true; } private void toolStripButton5_Click(object sender, EventArgs e) { ColorDialog cd = new ColorDialog(); if (cd.ShowDialog() == DialogResult.OK) { toolStripButton5.ForeColor = cd.Color; } } bool lin = false; private void linearGrandinToolStripMenuItem_Click(object sender, EventArgs e) { lin = true; } bool lc = false; private void linearGrandientToolStripMenuItem_Click(object sender, EventArgs e) { lc = true; } bool sg = false; private void linToolStripMenuItem_Click(object sender, EventArgs e) { sg = true; } private void toolStripButton11_Click(object sender, EventArgs e) { ImageProcessing obj = new ImageProcessing();
obj.Show(); } private void copyToolStripButton1_Click(object sender, EventArgs e) { } private void pasteToolStripButton1_Click(object sender, EventArgs e) { } private void Paint_MouseMove(object sender, MouseEventArgs e) { } bool dd = false; private void toolStripButton6_Click(object sender, EventArgs e) { dd = true; } private void newToolStripButton1_Click(object sender, EventArgs e) { Paint p = new Paint(); p.Show(); } private void exsitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog n = new OpenFileDialog(); n.ShowDialog(); string path = n.FileName; g.DrawImage(Image.FromFile(path), new Point(0, 0)); } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog s = new SaveFileDialog(); s.DefaultExt = "Jpeg"; s.Filter = "Jpeg files|*.jpg"; if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int width = p.Width; int height = p.Height; Bitmap bitMap = new Bitmap(p.Width, p.Height); p.DrawToBitmap(bitMap, new Rectangle(0, 0, p.Width, p.Height)); bitMap.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); } } private void newToolStripMenuItem_Click(object sender, EventArgs e) { Paint p = new Paint(); p.Show();
} private void toolStripComboBox2_Click(object sender, EventArgs e) { } } } IMAGE PROCESSING FORM: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Drawing2D; using System.Text; using System.Windows.Forms; namespace repaint_application { public partial class ImageProcessing : Form { public ImageProcessing() { InitializeComponent(); } private Size OriginalImageSize; private Size ModifiedImageSize; Bitmap newbitmap; int cropY; int cropX; int cropWidth; int cropHeight; public Pen cropPen; private Image Img; public bool Makeselection = false; private void LoadImage() { //we set the picturebox size according to image, we can get image width and height with the help of Image.Width and Image.height properties. int imgWidth = Img.Width; int imghieght = Img.Height; pictureBox1.Width = imgWidth; pictureBox1.Height = imghieght; pictureBox1.Image = Img; OriginalImageSize = new Size(imgWidth, imghieght); SetResizeInfo(); } private void SetResizeInfo() { label5.Text = OriginalImageSize.ToString(); label7.Text = ModifiedImageSize.ToString(); } private void openToolStripButton_Click(object sender, EventArgs e) { OpenFileDialog Dlg = new OpenFileDialog(); Dlg.Filter = "";
Dlg.Title = "Select image"; if (Dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Img = Image.FromFile(Dlg.FileName); //Image.FromFile(String) method creates an image from the specifed file, here dlg.Filename contains the name of the file from which to create the image newbitmap = new Bitmap(Dlg.FileName); LoadImage(); pictureBox1.Image = Img; } } private void saveToolStripButton1_Click(object sender, EventArgs e) { SaveFileDialog s = new SaveFileDialog(); if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK) { pictureBox1.Image.Save(s.FileName, System.Drawing.Imaging.ImageFormat.Png); } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { Cursor = Cursors.Cross; cropX = e.X; cropY = e.Y; cropPen = new Pen(Color.Black, 1); cropPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; } } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (pictureBox1.Image == null) { return; } if (e.Button == System.Windows.Forms.MouseButtons.Left) { pictureBox1.Refresh(); cropWidth = e.X - cropX; cropHeight = e.Y - cropY; pictureBox1.CreateGraphics().DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight); } } private void toolStripLabel8_Click(object sender, EventArgs e) { } private void toolStripButton11_Click(object sender, EventArgs e) { Cursor = Cursors.Default; if (cropWidth < 1) { return; } Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight); //First we define a rectangle with the help of already calculated points Bitmap OriginalImage = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height);
//Original image Bitmap _img = new Bitmap(cropWidth, cropHeight); // for cropinf image Graphics g = Graphics.FromImage(_img); // create graphics g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; //set image attributes g.DrawImage(OriginalImage, 0, 0, rect, GraphicsUnit.Pixel); pictureBox1.Image = _img; pictureBox1.Width = _img.Width; pictureBox1.Height = _img.Height; // PictureBoxLocation(); toolStripButton11.Enabled = false; } private void toolStripButton1_Click(object sender, EventArgs e) { Makeselection = true; toolStripButton11.Enabled = true; } private void toolStripButton2_Click(object sender, EventArgs e) { pictureBox1.Image = null; pictureBox1.Size = new System.Drawing.Size(500, 500); toolStripButton11.Enabled = false; } private void pictureBox1_Click(object sender, EventArgs e) { } private void BindDomainIUpDown() { for (int i = 1; i <= 999; i++) { domainUpDown1.Items.Add(i); } domainUpDown1.Text = "100"; } public static Bitmap AdjustBrightness(Bitmap Image, int Value) { Bitmap TempBitmap = Image; float FinalValue = (float)Value / 255.0f; Bitmap NewBitmap = new Bitmap(TempBitmap.Width, TempBitmap.Height); Graphics NewGraphics = Graphics.FromImage(NewBitmap); float[][] FloatColorMatrix ={ new float[] {1, 0, 0, 0, 0}, new float[] {0, 1, 0, 0, 0}, new float[] {0, 0, 1, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {FinalValue, FinalValue, FinalValue, 1, 1} }; ColorMatrix NewColorMatrix = new ColorMatrix(FloatColorMatrix);
ImageAttributes Attributes = new ImageAttributes(); Attributes.SetColorMatrix(NewColorMatrix); NewGraphics.DrawImage(TempBitmap, new Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, GraphicsUnit.Pixel, Attributes); Attributes.Dispose(); NewGraphics.Dispose(); return NewBitmap; } private void toolStripButton14_Click(object sender, EventArgs e) { zoom z = new zoom(); z.Show(); } private void toolStripLabel10_Click(object sender, EventArgs e) { } private void rotateRightToolStripMenuItem_Click(object sender, EventArgs e) { pictureBox1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone); pictureBox1.Refresh(); } private void rotateLeftToolStripMenuItem_Click(object sender, EventArgs e) { pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); pictureBox1.Refresh(); } private void rotateVerticalToolStripMenuItem_Click(object sender, EventArgs e) { pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY); pictureBox1.Refresh(); } private void rotateHorizontalToolStripMenuItem_Click(object sender, EventArgs e) { pictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX); pictureBox1.Refresh(); } private void trackBar1_Scroll(object sender, EventArgs e) { label2.Text = trackBar1.Value.ToString(); pictureBox1.Image = AdjustBrightness(newbitmap, trackBar1.Value); } private void toolStripButton3_Click(object sender, EventArgs e) { for (int x = 0; x < newbitmap.Width; x++) { for (int y = 0; y < newbitmap.Height; y++) {
Color orginalcolor = newbitmap.GetPixel(x, y); int grayscale = (int)((orginalcolor.R * .3) + (orginalcolor.G * .59) + (orginalcolor.B * .11)); Color newcolor = Color.FromArgb(grayscale, grayscale, grayscale); newbitmap.SetPixel(x, y, newcolor); } } pictureBox1.Image = newbitmap; } private void toolStripButton4_Click(object sender, EventArgs e) { for (int x = 0; x < newbitmap.Width; x++) { for (int y = 0; y < newbitmap.Height; y++) { Color pixel = newbitmap.GetPixel(x, y); int red = pixel.R; int green = pixel.G; int blue = pixel.B; newbitmap.SetPixel(x, y, Color.FromArgb(255 - red, 255 - green, 255 - blue)); } } pictureBox1.Image = newbitmap; } private void domainUpDown1_SelectedItemChanged(object sender, EventArgs e) { int percentage = 0; try { percentage = Convert.ToInt32(domainUpDown1.Text); ModifiedImageSize = new Size((OriginalImageSize.Width * percentage) / 100, (OriginalImageSize.Height * percentage) / 100); SetResizeInfo(); } catch (Exception ex) { MessageBox.Show("Invalid Percentage"); return; } } private void button1_Click(object sender, EventArgs e) { Bitmap bm_source = new Bitmap(pictureBox1.Image); // Make a bitmap for the result. Bitmap bm_dest = new Bitmap(Convert.ToInt32(ModifiedImageSize.Width), Convert.ToInt32(ModifiedImageSize.Height)); // Make a Graphics object for the result Bitmap. Graphics gr_dest = Graphics.FromImage(bm_dest); // Copy the source image into the destination bitmap. gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1); // Display the result. pictureBox1.Image = bm_dest; pictureBox1.Width = bm_dest.Width; pictureBox1.Height = bm_dest.Height; } private void ImageProcessing_Load(object sender, EventArgs e)
{ BindDomainIUpDown(); } private void copyToolStripButton_Click(object sender, EventArgs e) { OpenFileDialog Dlg = new OpenFileDialog(); Dlg.Filter = ""; Dlg.Title = "Select image"; if (Dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Image imgToCopy = Image.FromFile(Dlg.FileName); Clipboard.SetImage(imgToCopy); } } private void cutToolStripButton_Click(object sender, EventArgs e) { } private void pasteToolStripButton_Click(object sender, EventArgs e) { pictureBox1.Image = Clipboard.GetImage(); } private void vScrollBar1_Scroll(object sender, ScrollEventArgs e) { } } } ZOOM WINDOW: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace repaint_application { public partial class zoom : Form { public zoom() { InitializeComponent(); } Bitmap b; Graphics g; int zm = 2; private void zoom_Load(object sender, EventArgs e) { } private void timer1_Tick(object sender, EventArgs e) { b= new Bitmap(pictureBox1.Width/zm,pictureBox1.Width/zm,System.Drawing.Imaging.PixelFormat.Format32bppArgb); g = Graphics.FromImage(b); g.CopyFromScreen(MousePosition.X - pictureBox1.Width / (zm * 2), MousePosition.Y - pictureBox1.Height / (zm * 2), 0, 0, pictureBox1.Size, CopyPixelOperation.SourceCopy); pictureBox1.Image = b; }