Crop image using 2 clicked points on image.

HI,
 I want to crop an image  based on 2 clicked points.
For ex:
this is an image to be crop:
take 1st click point as center and 2nd click point as radius and crop that part as square and forms new image.
And new image should be something like this:
 This is what I want.
I have done getting center point using code below:
OpenFileDialog op = new OpenFileDialog();
ImageBrush ib = new ImageBrush();
private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
op.Title = "Select a picture";
op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
"JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
"Portable Network Graphic (*.png)|*.png";
if (op.ShowDialog() == true)
imgBackground.Source = new BitmapImage(new Uri(op.FileName));
private BitmapSource CutImage(BitmapImage img, Point p1, int width, int height)
return new CroppedBitmap(img, new Int32Rect(Convert.ToInt32(p1.X), Convert.ToInt32(p1.Y), width, height));
double xAxis = 0.00;
double yAxis = 0.00;
private void imgBackground_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
Point center = e.GetPosition(imgBackground);
Point border = e.GetPosition(imgBackground);
xAxis = center.X;
yAxis = center.Y;
ib.ImageSource = CutImage(new BitmapImage(new Uri(op.FileName)), new Point(xAxis, yAxis), 300, 300);
CanvasPanel.Background = ib;
XAML code:
<Button Height="70" Width="70" Margin="6,1,892,929" Name="btnBrowseImage">
<Image x:Name="browseIcon" Source="D:\WPF\Projects\TabControlVRI_18_12_2014\Images\img.png" MouseLeftButtonDown="Image_MouseLeftButtonDown_1"/>
</Button>
<Image Name="imgBackground" HorizontalAlignment="Center" VerticalAlignment="Center" Height="799" Width="799" MouseLeftButtonDown="imgBackground_MouseLeftButtonDown" Stretch="Uniform">
</Image>
I hope now question is understandable.
Plz, suggest me the way to get this.
Regards,
Viswa.

Hi,
I want to do in WPF coding.
I need to add that cropped image as background to canvas in WPF.
User have to select image and he wants to crop image using 2 points then it has to reflect as background to canvas.

Similar Messages

  • How will Aperture treat Nikon raw images which have been enhanced using Capture NX2 software?  Some are cropped and "developed" and some have been enhanced using the control point technology.  I have NIK sw as a plug-in in aperture.

    How will Aperture treat Nikon raw images which have been enhanced using Capture NX2 software?  Some are cropped and "developed" and some have been enhanced using the control point technology.  I have NIK sw as a plug-in in aperture.

    Actually, there is a Nik/Nikon connection — but I am pretty sure it is irrelevant to the OP's question. The connection is that Capture NX2 was written as a joint venture between Nikon and Nik. (The name similarity is a coincidence.)
    Capture NX2 is a cool program that incorporates the features of Nik's Viveza and Nikon's Raw processing engine, along with some other powerful image adjustment features. It provides, like Aperture, a losses workflow. Unlike Aperture, the adjustments (Edit Steps in C-NX terminology) are saved in the original NEF file along with the un-altered raw data. Multiple versions can be saved in a single NEF.

  • Wrong Out while Cropping image using different java version

    Hi,
    my task is to crop the image based on x,y,w,h coordinates, but thing is i am getting different cropped images while using java 1.6 and java 1.7.
    in java 1.6 the x and y coordinates starting from 0,0 instead of given values.
    please find the code below:
    import java.awt.Image;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import javax.imageio.ImageIO;
    public class CropImage {
    Image image;
    // Insets insets;
    BufferedImage img = null;
         public CropImage(){
              try{
    img = ImageIO.read(new File("D:/temp/","Capture.gif"));
    File outputfile = new File("D:/temp/","saved.gif");
    // 49,158,58,7 -x,y,w,h
    ImageIO.write(img.getSubimage(58, 6, 158, 50), "gif", outputfile);
              }catch(Exception es){
                   es.printStackTrace();
         public static void main(String args[]){
              new CropImage();
    Thanks,
    shashanka.
    Edited by: user8956018 on Dec 23, 2012 10:54 PM

    Note 791765 - Mixed JSESSIONID Cookies from Different Servers - resolved the issue

  • Crop Image using applescript?

    Hi all
    I'm trying to set up a script that will batch crop a bunch of files to 320X320 (album artwork size). However, I have yet to come across a sample/tutorial of how to set up the actual crop commands. Is cropping images even possible with applescript?

    You're right it does work now!
    I've tried to adapt Camelot's code to my version of the script but for some reason, the images don't get cropped.
    here is my code so far:
    -- global variable declarations
    global _widthHeight
    global _folderA
    global _folderB
    global _workFilesInA
    global _workFilesInB
    global _theImage
    set _widthHeight to the text returned of (display dialog "Enter dimension for width and height:" default answer "320")
    set _folderA to (choose folder)
    tell application "Finder"
    set _workFilesInA to every file of folder _folderA
    end tell
    tell application "Finder" -- creation of temporary folder
    if (the folder "path:processedImages" exists) then
    set _theAns to the button returned of (display dialog "A folder named processedImages already exists." buttons {"Cancel", "Yes"} default button "Yes")
    if _theAns is "Yes" then
    tell application "Finder"
    delete the folder "path:processedImages"
    set _folderB to (make new folder at "path:Desktop:" with properties {name:"processedImages"})
    end tell
    end if
    else
    set _folderB to (make new folder at "Path:Desktop:" with properties {name:"processedImages"})
    end if
    end tell
    -- work code
    if (count of _workFilesInA) is not 0 then
    repeat with i from 1 to count of _workFilesInA
    try
    tell application "Finder"
    duplicate item i of _folderA to _folderB
    end tell
    on error errmess
    display dialog "This error occured: " & errmess
    end try
    end repeat
    end if
    tell application "Finder" -- crop files in temporary folder
    set _folderB to "Path:processedImages"
    set _workFilesInB to every file in folder _folderB
    tell application "Image Events"
    repeat with i from 1 to count of _workFilesInB
    crop item i to dimensions {_widthHeight, _widthHeight} **********
    save item i
    end repeat
    end tell
    end tell
    everything works up to the **********. The events log tells me that the items were cropped (it even cycles through the), but upon inspecting the images, no cropping is evident.

  • LR4 beta white balance on cropped images

    I'm not sure if this has been discussed, I could not find a post with silimar issues.
    LR4 Beta 64 on WinVista : Nex 5N raw files
    WB picker on a cropped image seems to give variable (and wrong) results
    I wanted to tweak WB an image that I'd previously cropped and made some adjustments to....WB was already close, the picker on a white fishing bouy was at ~90/88/91. Clicking the picker on bouy gave a strong red shift, about +5 on the red.
    1st time I did it I thought I'd jerked the mouse somewhere, tried it again.. and again with similar results. Repeated several time.
    I opened LR3 and had no problems with the same image.
    I reopened LR4B and got the same problem again.
    Undid the crop and the WB adjustment was fine.
    I went back to LR3 and cropepd the same image the same way and WB was fine.
    Went back to Lr4B and again, WB was off.
    I reset the image so that it had no other adjustments. WB was OK but again when I cropped it it was off.
    Opened another image and did the same thing. ie full image WB was OK, cropped I got a +5 or so shift, although this time in blue.
    Tried it with a different crop and got a -15 on red.
    WB zoom level was at max
    Mike

    Eric,
    Take just about any photo and crop so all the sides are moved toward the middle. It isn't hard to find a point on the image where the white balance dropper looks like it's over a near-grey(and its numbers say near-grey), but when you click, the picture gets an extreme colour cast. And the point where you click doesn't go grey, either, but moves much farther from grey.
    Here's the crop:
    Here's what happens when the eyedropper is over the almost-grey snow:
    Note what's happening in the Navigator preview. It's as if the eyedropper were over the yellow jacket, but the numbers on the loupe show grey.
    Hal

  • How to add crop image control in wpf in simpler way..?

    HI,
     It is extended question to other question which is in this following link:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/cc44411b-e105-45d4-9e26-f0c08252b783/how-to-get-transparency-scroll-bar-to-view-background-image-of-canvas?forum=wpf&prof=required
    Actually, now I'm getting full image as background to canvas.
    I need to crop image in "Change-Background" tab, so that I can get cropped image as background brush to canvas in tools tab.
    I hope question is Understandable. If not ask me here.
    Regards,
    Viswa.

    Hi Franklin,
    Can you plz give XAML code too?
    And I need, the user select these {
    newPoint(0,0),300,300) }
    2 points on click event on Image, and then can crop it from this line from above code
    ib.ImageSource = CutImage(new BitmapImage(new Uri(op.FileName)), new Point(0, 0), 300, 300);
     I hope you got my issue.
    Regards,
    Viswa

  • Crop Image Tool - Illustrator CC 2014

    I am looking for tutorials on how to use the "Crop Image Tool" in Illustrator CC 2014. Can anyone point me in the right direction please?

    Great to hear that Nick
    Hi Jacob,
    Long time. Winter is at our doors here. I am OOTO for this Thursday & Friday + Weekend. Will get back on the forums soon.
    With Best Regards,
    Raghuveer

  • •When cropping images, completely remove the borders to reduce excess light interference.

     In the maunual, this is the last line in the instructions.  "When cropping images, completely remove the borders to reduce excess light interference."
    What does this mean?  Do you have to remove the fromes from the slides before scanning or does the attachment hold the slide in it's frame?  What does cropping images refer to -  the digital copy or the original frame that you are copying from?

    Hello Gingerlee, and welcome to the HP Forums, I hope you enjoy your experience!
    I see you have questions about cropping options.  I would love to try and help you, but I do need a little information first. I am linking a few HP Support documents below that will show you how to find your product number. Also, please include which operating system you are using. Also, if you're using Windows, please include whether your operating system is 32-bit or 64-bit. With this information and the product number we can provide you with accurate information.
    How Do I Find My Model Number or Product Number?
    Mac OS X: How Do I Find Which Mac OS X Version Is on My Computer?
    Which Windows operating system am I running?
    Is the Windows Version on My Computer 32-bit or 64-bit?
    Please let me know what you find.  Thanks for posting on the HP Forums!
    Please click “Accept as Solution " if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the right to say “Thanks" for helping!
    Jamieson
    I work on behalf of HP
    "Remember, I'm pulling for you, we're all in this together!" - Red Green.

  • Get Cropped Image to Fit Screen?

    Whenever I crop a photo the new image snaps to the corner and gets very small. Is there a way to change this so my new image stays floating AND fits the screen? I thought that in the past whenever I cropped an image it would fill the window the same size of the un-cropped photo. The only thing I can do now is after I make the crop select "fit to screen" (Ctrl-0) to get the image view large again. I don't remember having to do this. I crop a lot of photos so I'd really like a way to make the crop instantly go to a large image. Did I mess up my settings some where or do I have to click "fit to screen" after every crop?

    Usually when you crop an image in the full edit mode,
    the cropped image will be at the same viewing percent
    as the uncropped image. In other words if your image was at 100%
    view (actual pixels), the cropped image will also be at 100% view.
    Sometimes in the floating image mode (non tabbed view) the window will
    get smaller and end up on the left top of the screen (don't know why).
    If your using pse8-9, you can work in the tabbed viewing mode to prevent the window resizing,
    but the image itself will still not fill the screen, only the document window.
    In earlier versions you can use the maximize window mode.
    MTSTUNER

  • Cropping Images with Clipping Masks | Learn Illustrator CS6 | Adobe TV

    In this video you will learn a quick and easy method for cropping images in Adobe Illustrator CS6 and CS5. Using clipping masks allows you to retain the area of the image you cropped out as well as modify the clipping path later on.
    http://adobe.ly/V8tW7S

    Is there a way to make a clipping mask for a many-layered image without collapsing all the layers? I'd love to keep my image as is (it's quite complex), I just want to crop the entire thing.
    thanks!

  • Cropping Images with Opacity Masks | Learn Illustrator CS6 | Adobe TV

    In this video you will learn a versatile method for cropping images in Adobe Illustrator CS6 and CS5. Using opacity masks allows you to retain the area of the image you cropped out, modify the clipping path later, and use complex blending modes, transparencies, and knockout groups.
    http://adobe.ly/V8tTZD

    Firstly great tutorial.
    Anyway I initially started a thread in the forums which lead me here regarding the use of opacity masks, I'm having real problems finding a solution to my specific problem.
    I've got 2 issues I'm trying to solve, the first is how do I show just a portion an object above another even though it sits in a layer behind.
    The second is I have an object with a linear gradient applied and I want to add yet another gradient just to a certain part of that object in order to make it fade out in a certain way.
    I've spent hours pouring through the help topics but nothing seems to fit my exact problem, sorry for asking questions here but I'm really stumped and I think an opacity mask would do the trick, I'm just not sure how to execute it.
    Thanks heaps.
    http://forums.adobe.com/message/5125695#5125695

  • Why are my cropped images not printing at the size I have cropped them to?!

    Hey!
    I know how to crop images to specific sizes using either the rectangular marquee or crop tool. However, I am needing to print a number of small images, so want to compile them into one document to save paper. Once the image is cropped, it shows up in 'image size' as being the required size, however, when I copy and paste it into another document in an attempt to arrange it on a page with other cropped images, the images come out at about half the specified size when I print them.
    Is it to do with the view I am using, because it doesn't seem to matter whether I set it to 'print size' or 'actual pixels'?
    I can't seem to find an answer to this, and I'm sure that I didn't have a problem with this when I was using photoshop more regularly a few years ago!

    Hello,
    You need to ake sure the target document and the source documents have the same"resolution", in other words the same PPI.
    You could also use the Edit>Place command, which will respect the print dimensions of the source photo, but import it as a Smart Object.
    CB

  • URGENT HELP plz! crop image

    I have an image
    when loaded into my program, i have the getScaledInstance to about half of the size
    and then i want to crop on that scaled image icon, how can i do that?
    i tried the crop image filter, but it always need to getImage().getSource() which require the cooridnates of the original image (non scaled one)
    i do not have the cooridnate of the original image, i just have the scaled image coordinate part for cropping. How can i crop?

    Hey, here's some code:
              URL url = getClass().getClassLoader().getResource("some_image.jpg");
              Image rawImage = ImageIO.read(url);
              Image bufferedImage = new BufferedImage(X, X, BufferedImage.TYPE_INT_ARGB);
              // Perform your scaling here.
              bufferedImage.getGraphics().drawImage(rawImage, 0, 0, X, X, X);
              MediaTracker tracker = new MediaTracker(this);
              tracker.addImage(bufferedImage, 1);
              tracker.waitForID(1);
              Image cropImage = bufferedImage.getSubimage(X, X, X, X);Is this anymore useful to you?
    Warm regards.

  • Ease of rotating and cropping images in CS6

    There is much I like about the new crop: Rotating the image instead of the box is SO much easier and the straighten option is a great time saver.
    But in one instance, I'm finding cropping in CS6 to be harder: Cropping images that are not correctly oriented in the first place.  Rotating an image 90-degrees was a snap in CS2: Alt-I/E/0.  The shortcut keys are gone in CS6, so using the rotation command is no longer quick.
    But I can do it in the crop box, right?  True -- but not easily.  The image is landscape, the crop box is portrait.  With the crop tool selected, holding the shift key down to get fixed-increment rotations doesn't work: Pressing the SHIFT key changes the cursor from rotation to the crop cursor.  To get the rotation, I have to start rotating the image and then press SHIFT to get 15-degree increments.  A few moments later, I have rotated the image into portrait orientation -- and the crop box is now centered on the image, but it is set to crop the middle.  I have to drag the handles out to get approximately what I want: The full image in the crop box.  (What I want is what I would get if I rotate the image with the Rotate command, then control-zero to fill the screen, and then select the crop tool.)
    We rotate a lot of images.  It's easy to do in CS2 and the two approaches I've found for CS6 are both awkward.  The new crop tool has replaced the dual arrows in older versions (to swap the horizontal and vertical sizes) with a rotation arrow.  I think you should restore the arrows (and their function) -- then use the rotate button to rotate the image, not the crop box.  (Isn't that the design center for the new crop box?  We're moving the image, not the crop box.)

    Howard, thanks for the tip about the X key; didn't realize it worked that way when the crop tool is active.  But in this case I had set the crop box dimenions, so the crop box starts out with the correct orientation.  Having played with this for a day, I conclude that the best approach for this task is to restore the old keyboard conventions for image rotation and rotate the image before launching the crop tool.
    I stand by my observation that the rotate key should affect the image, not the crop box because that is consistent with the new cropping paradigm: We rotate the image, not the crop box.  I realize making a change this late in the development cycle is awkward -- but if CS6 ships with this behavior, it will become even harder to change later -- and the user interface should be as consistent as possible.
    Noel, you are correct: The images are coming from scanned film.  All frames get scanned with the same orientation.  I want to avoid the "Patient: Doctor, it hurts when I do this.  Doctor: Then don't do that!" scenario.  Granted: If images are "correctly" oriented, this issue doesn't arise.  But not all images are oriented correctly and CS6 should be at least as graceful in handling the task as previous versions.

  • I need to crop image in TIFF format. what product i need to buy

    i need to crop image in TIFF format. what product i need to buy

    Photoshop should be able to handle cropping your TIFF file, possibly Photoshop Elements as well which would cost less.  You should get the trial version to make sure rather than buying before trying.
    You might also want to check if you already have something on your machine that can do it.  On a PC you should be able to right click the image and choose "Open With" whereby a menu of programs should appear with programs that can open the file.  You can check to see if any of those listed provide the cropping tool.
    If you have further questions you should try posting in the Photoshop forum instead of here (http://forums.adobe.com/community/photoshop?view=discussions).  This forum is primarly for questions about downloading and installing Adobe applications.

Maybe you are looking for