5 Replies - 5965 Views - Last Post: 01 June 2011 - 02:26 PM

#1 Hockey   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-May 11

how to add selection tool on an image in windows phone 7 application ?

Posted 31 May 2011 - 06:19 AM

hi,
i m working as windows phone 7 developer.i am developing a photo editor application.Any one have idea how to add selection control in application that can select a particular part of an image,n this selection rectangle must be resizable and movable as available in photoshop.
Is This A Good Question/Topic? 0
  • +

Replies To: how to add selection tool on an image in windows phone 7 application ?

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: how to add selection tool on an image in windows phone 7 application ?

Posted 31 May 2011 - 06:33 AM

Track the mouse movement and mouse down actions.

You then copy the area from the original from within that moused area.

So if they mousedown at 10,30 and mouseup at 100,300 they have just given you the rectangle area to copy from.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14243
  • View blog
  • Posts: 57,137
  • Joined: 12-June 08

Re: how to add selection tool on an image in windows phone 7 application ?

Posted 31 May 2011 - 07:02 AM

You also may want to check out my tutorial on making a "rubberband" rectangle on an image. Granted it's in VB.NET the concepts are highly transferable.

http://www.dreaminco...bberband-shape/
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: how to add selection tool on an image in windows phone 7 application ?

Posted 31 May 2011 - 07:17 AM

View PostHockey, on 31 May 2011 - 07:19 AM, said:

...this selection rectangle must be resizable and movable as available in photoshop.


Now that you have the basics you expand from there. You're selection has to be treated as an object. You have to store it, probably as a rectangle. You have to react to the mouse conditions. For example if the mouse is directly over the right edge of your selection box when the user clicks down, they mean to grab that edge. So now you react to the mousemove a little differently and move the entire side by adjusting the 'width' value, or the X coordinate of the LowerRight corner point - depending on how you are storing the selection box.

But you also want it moveable, so if they click down within all four sides, that must be the movement, so now dragging the mouse moves all the coordinates together.


Unless you go to a plan 'B' approach where you also draw control handles in the corners. Now the user must click-drag on a handle to make a move or resize action.

The look & feel of the GUI is entirely up to you and your needs.
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: how to add selection tool on an image in windows phone 7 application ?

Posted 31 May 2011 - 07:22 AM

You may also need to factor in magnification when it comes time to actually take the selection from the original. Assuming a full-size image won't fit on an itty-bitty screen.

So if you are showing a reduced view, let's say 25% for conversation.

Your 1000,1000 original will be displayed at 250 x 250.

So a selection on screen from 50,100 to 100,200 has to be translated to the full size image becoming 200, 400 to 400,800 (divide the point by the factor of .25)
screen point 50, 100
becomes 50/.25 , 100/.25
Fullsize point 200, 400
Was This Post Helpful? 0
  • +
  • -

#6 Core   User is offline

  • using System.Linq;
  • member icon

Reputation: 783
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Re: how to add selection tool on an image in windows phone 7 application ?

Posted 01 June 2011 - 02:26 PM

Since this is Windows Phone 7, I wrote an example that is exactly what you are looking for:
Custom image cropping in Windows Phone 7 - Part 1 of 2
Custom image cropping in Windows Phone 7 - Part 2 of 2

You might skip the actual cropping mechanism, but you can see how I implemented the selection rectangle on top of an image that is loaded dynamically.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1