Image Open : Image « 2D Graphics « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » 2D Graphics » ImageScreenshots 
Image Open
  
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
   
class ImageOpen: Form
{
     protected string strProgName;
     protected string strFileName;
     protected Image  image;
   
     public static void Main()
     {
          Application.Run(new ImageOpen());
     }
     public ImageOpen()
     {
          ResizeRedraw = true;
   
          Menu = new MainMenu();
          Menu.MenuItems.Add("&File");
          Menu.MenuItems[0].MenuItems.Add(new MenuItem("&Open..."
                                   new EventHandler(MenuFileOpenOnClick),
                                   Shortcut.CtrlO));
     }
     void MenuFileOpenOnClick(object obj, EventArgs ea)
     {
          OpenFileDialog dlg = new OpenFileDialog();
   
          dlg.Filter = "All Image Files|*.bmp;*.ico;*.gif;*.jpeg;*.jpg;" +
                              "*.jfif;*.png;*.tif;*.tiff;*.wmf;*.emf|" +
                       "Windows Bitmap (*.bmp)|*.bmp|" +
                       "Windows Icon (*.ico)|*.ico|" +
                       "Graphics Interchange Format (*.gif)|*.gif|" +
                       "JPEG File Interchange Format (*.jpg)|" +
                              "*.jpg;*.jpeg;*.jfif|" +
                       "Portable Network Graphics (*.png)|*.png|" +
                       "Tag Image File Format (*.tif)|*.tif;*.tiff|" +
                       "Windows Metafile (*.wmf)|*.wmf|" +
                       "Enhanced Metafile (*.emf)|*.emf|" +
                       "All Files (*.*)|*.*";
   
          if (dlg.ShowDialog() == DialogResult.OK)
          {    
   
               try
               {
                    image = Image.FromFile(dlg.FileName);
               }
               catch (Exception exc)
               {
                    Console.WriteLine(exc.Message);
                    return;
               }
               strFileName = dlg.FileName;
               Text = Path.GetFileName(strFileName);
               Invalidate();
          }
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics grfx = pea.Graphics;
   
          if (image != null)
               grfx.DrawImage(image, 00);
     }
}

   
  
Related examples in the same category
1.Load Image from an image file with Exception handler
2.Image.FromStream: load image from stream
3.Shrink ImageShrink Image
4.Shear ImageShear Image
5.Clone ImageClone Image
6.Get Image Resolution and Image size and Display sizeGet Image Resolution and Image size and Display size
7.Draw image based on its sizeDraw image based on its size
8.Set image resolution and paint itSet image resolution and paint it
9.Load image and displayLoad image and display
10.Fill Ellipse with image based Texture BrushFill Ellipse with image based Texture Brush
11.Image Save
12.Thumbnail Image
13.Draw on Pixel-Size Image
14.Draw text on an Image
15.Partial Image Rotate
16.Partial Image Stretch
17.Draw Partial Image
18.Image At Points (Draw part of the image)
19.Image Reflection
20.Image Scale Isotropic
21.Image Scale To Rectangle
22.Center Pixel-Size Image by using Image.Width and Image.Height
23.Center an Image (VerticalResolution, HorizontalResolution)
24.Load image from a URL(Web) and draw it
25.Scribble with Bitmap
26.Image Flipping and Rotating
27.Image.GetThumbnailImage
28.Image Zoom
29.Create Thumbnail
30.Image Resize
31.Get Bitmap Source
32.Get Bytes From BitmapSource
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.