Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. change the following code [modified]

change the following code [modified]

Scheduled Pinned Locked Moved C#
graphics
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maheshwari vetri
    wrote on last edited by
    #1

    private void btnOOImg_Click(object sender, EventArgs e)
    {
    string imgFileName;
    Bitmap img = null;
    Color c;
    int i, j;
    openFileDialog1.Filter = "All Image Files|*.bmp;*.ico;*.cur|All files (*.*)|*.*";
    openFileDialog1.FileName = null;
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
    imgFileName = openFileDialog1.FileName;
    img = (Bitmap)Image.FromFile(imgFileName);
    for (i = 0; i < img.Width - 1; i++)
    {
    for (j = 0; j < img.Height - 1; j++)
    {
    c = img.GetPixel(i, j);
    imgO[i, j] = c.R;
    // MessageBox.Show("" + imgO[i, j]);
    }
    }
    picOriginal.Image = img;
    }
    }

    this code restricts certain images. i want it to change accept all images in as a file not inside a picture box

    modified on Tuesday, December 7, 2010 11:55 AM

    H 1 Reply Last reply
    0
    • M maheshwari vetri

      private void btnOOImg_Click(object sender, EventArgs e)
      {
      string imgFileName;
      Bitmap img = null;
      Color c;
      int i, j;
      openFileDialog1.Filter = "All Image Files|*.bmp;*.ico;*.cur|All files (*.*)|*.*";
      openFileDialog1.FileName = null;
      if (openFileDialog1.ShowDialog() == DialogResult.OK)
      {
      imgFileName = openFileDialog1.FileName;
      img = (Bitmap)Image.FromFile(imgFileName);
      for (i = 0; i < img.Width - 1; i++)
      {
      for (j = 0; j < img.Height - 1; j++)
      {
      c = img.GetPixel(i, j);
      imgO[i, j] = c.R;
      // MessageBox.Show("" + imgO[i, j]);
      }
      }
      picOriginal.Image = img;
      }
      }

      this code restricts certain images. i want it to change accept all images in as a file not inside a picture box

      modified on Tuesday, December 7, 2010 11:55 AM

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      The formats supported by the Image class are listed here[^]. Simply change your OpenFileDialog Filter to include those you are interested in.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      M 1 Reply Last reply
      0
      • H Henry Minute

        The formats supported by the Image class are listed here[^]. Simply change your OpenFileDialog Filter to include those you are interested in.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        M Offline
        M Offline
        maheshwari vetri
        wrote on last edited by
        #3

        i tried changing.i have a index error. can you give me a particular sytax

        H 1 Reply Last reply
        0
        • M maheshwari vetri

          i tried changing.i have a index error. can you give me a particular sytax

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          You currently have:

                 openFileDialog1.Filter = "All Image Files|\*.bmp;\*.ico;\*.cur|All files (\*.\*)|\*.\*";
          

          To add a filter for PNG files (for example) simply add the filename template between 'cur' and the '|' before 'All Files', not forgetting to separate it by a semi-colon.

                 openFileDialog1.Filter = "All Image Files|\*.bmp;\*.ico;\*.cur**;\*.png**|All files (\*.\*)|\*.\*";
          

          I have tried to make my additions stand out by superscripting it. Have a go with the others yourself.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups