Click here to Skip to main content
14,639,013 members
Rate this:
Please Sign up or sign in to vote.
See more:

I am developing an application to upload an image in WPF .

I need to keep the original image as a thumbnail image after i upload and then later that image can be zoomed using zoom in and zoom out.

Please suggest me any links or way for this .

I am using WPF 2010 .

Rate this:
Please Sign up or sign in to vote.

Solution 1

HI Sophia,

I would like to give some basic idea to implement the requirement into code,

I tried in silverlight, but not in WPF. So i'll give what i did on Silverlight for you here.

Just try this:

Once file is uploaded,

Step 1: Read the actual width and height and store it in variable.
Step 2: Now reduce the image size(eg: 128x128) and place it in thumbnail picture box.
Step 3: Place two button in the form for your convenient or horizontal slider(if you aware of it)
Step 4: In Button_Click() increase the width and height by 10px/Click or if its Slider try Slider_Change()

Hope this could be helpful, if u want i'll place the silverlight code for you.
Sophia Ranjani Elango 14-Nov-12 7:29am
Hi Prabhakar can you please place the silverlight code also .
♥…ЯҠ…♥ 14-Nov-12 7:45am
Do you know how to upload a attachment here?
Rate this:
Please Sign up or sign in to vote.

Solution 2

This is not Silverlight code.....

Try this C# code,

First place List control(Display list of images),Textbox control, 3 buttons(One for Browse,One for Zoomin, one for ZoomOut)

Note change the name of the control resp.

Now try this code:

private void btnBrowse_Click(object sender, EventArgs e)


           if(dlgFolder.ShowDialog() == DialogResult.OK)
               var filePaths = Directory.GetFiles(strFldrpath, "*.*", SearchOption.AllDirectories)
           .Where(s => s.EndsWith(".gif") || s.EndsWith(".jpg") || s.EndsWith(".bmp"));

               //string[] filePaths = Directory.GetFiles(strFldrpath, strExt);
               int length = filePaths.Count();
               int i = 0;
               while (length > i)

                   lstImagename.Items.Add(new FileInfo(filePaths.ElementAt(i).ToString()).Name);
               if (lstImagename.Items.Count == 0)
                   MessageBox.Show("Image(s) not available", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   DialogResult resYesNo;
                  resYesNo = MessageBox.Show("Do you want to continue ", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                  if (resYesNo == DialogResult.Yes)
                      btnBrowse_Click(sender, e);
                  //Nothing in here
                      txtFldrpath.Text = "";

               txtFldrpath.Text = strFldrpath;

      private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
           strImgName = txtFldrpath.Text + "\\" + lstImagename.SelectedItem;
           pbxImg.Image = Image.FromFile(strImgName);

      private void buttin_Click(object sender, EventArgs e)
          if ((pbxImg.Width <= 322) & (pbxImg.Height <= 290))
              pbxImg.Width = pbxImg.Width + 10;
              pbxImg.Height = pbxImg.Height + 10;

      private void buttout_Click(object sender, EventArgs e)
          if ((pbxImg.Width >= 1) & (pbxImg.Height >= 1))
              pbxImg.Width = pbxImg.Width - 10;
              pbxImg.Height = pbxImg.Height - 10;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100