Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I Have hard problem i can't fix it my self.
I want to cropping image1 and after get picture from camera task.

C#
private void button1_Click(object sender, RoutedEventArgs e)
{
    CameraCaptureTask task = new CameraCaptureTask();
    task.Completed += (s, evt) =>
    {
        if (evt.Error == null && evt.TaskResult == TaskResult.OK)
        {
            bmpImage.SetSource(evt.ChosenPhoto);
            image1.Source = bmpImage;
        }
    };
    task.Show();
}


exp: image1 have resolution 1000px * 1000px

now I want add button2 to crop image in image1:
from x=100 to x=800
from y=200 to y=700
so I have new imgae1 resolution 700*500.
I Found Solution for this in http://msdn.microsoft.com/en-us/library/ms752345.aspx[^]
here the code:

C#
// Create an Image element.
            Image croppedImage = new Image();
            croppedImage.Width = 200;
            croppedImage.Margin = new Thickness(5);

            // Create a CroppedBitmap based off of a xaml defined resource.
             
            CroppedBitmapcb = new CroppedBitmap(
               (BitmapSource)this.Resources["masterImage"],
               new Int32Rect(30, 20, 105, 50));       //select region rect
            croppedImage.Source = cb;                 //set image source to cropped


The code above is error the namespace 'CroppedBitmap' not found.
please help my problem
Posted
Updated 30-Jan-12 5:09am
v2

1 solution

Have you added 'PresentationCore.dll' as reference?

If yes then, have you refereed Imaging namespace?

C#
using System.Windows.Media.Imaging;
 
Share this answer
 
Comments
bagus bujangga 30-Jan-12 23:08pm    
Where to add "PresentationCore.dll" ??

I Have refereed imaging namespace
using System.Windows.Media.Imaging;
Member 9861929 19-Mar-13 8:20am    
I want to crop the image in my wp7 app.I have 1 rectangle and if I would increase the size of rectangle exactly that part will get cropped please give me the soln and I use WritableBitmap Class in my whole app.Please give me solution......Sory my English is not so good

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900