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

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 .
 
Thanks
Sophia
Posted 14-Nov-12 0:32am
Rate this: bad
good
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.
  Permalink  
Comments
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?
Rate this: bad
good
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)
       {
 
           lstImagename.Items.Clear();
 
           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);
                   i++;
               }
               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);
                  }
                  else
                  {
                  //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;
          }
      }
       }
  Permalink  
v2

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

  Print Answers RSS
0 Nirav Prabtani 304
1 OriginalGriff 237
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2014
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