Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: WPF C#4.0

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 .
Posted 14-Nov-12 1:32am
Rate this: bad
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;
Rate this: bad
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 at 14-Nov-12 7:29am
Hi Prabhakar can you please place the silverlight code also .
rk_prabakar at 14-Nov-12 7:45am
Do you know how to upload a attachment here?

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 420
1 OriginalGriff 344
2 Peter Leow 200
3 John C Rayan 126
4 CHill60 90
0 Sergey Alexandrovich Kryukov 7,393
1 OriginalGriff 5,711
2 Peter Leow 4,157
3 CHill60 2,858
4 Mika Wendelius 2,850

Advertise | Privacy | Mobile
Web03 | 2.8.150224.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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