简体   繁体   中英

Crop an Image in nokia Imaging SDK 1.2?

Can you give me a sample code for crop an Image using Nokia Imaging SDK 1.2 ? As you know the "Editing Session" class, that I use for cropping Image has gone in SDK 1.2. Thanks for your attention.

This is an excerpt from the nokia api reference documentation which can be found here:

http://developer.nokia.com/resources/library/Imaging_API_Ref/nokiagraphicsimaging-namespace/cropfilter-class.html

This sample takes CameraCaptureTask result photo and applies a [crop] filter to it.

async void CaptureTask_Completed(object sender, PhotoResult e)
{
    // Create a source to read the image from PhotoResult stream
    using (var source = new StreamImageSource(e.ChosenPhoto))
    {
        // Create effect collection with the source stream
        using (var filters = new FilterEffect(source))
        {
            // Initialize the filter 
            var sampleFilter = new CropFilter(new Windows.Foundation.Rect(0, 0, 500, 500));

            // Add the filter to the FilterEffect collection
            filters.Filters = new IFilter[] { sampleFilter };

            // Create a target where the filtered image will be rendered to
            var target = new WriteableBitmap((int)ImageControl.ActualWidth, (int)ImageControl.ActualHeight);

            // Create a new renderer which outputs WriteableBitmaps
            using (var renderer = new WriteableBitmapRenderer(filters, target))
            {
                // Render the image with the filter(s)
                await renderer.RenderAsync();

                // Set the output image to Image control as a source
                ImageControl.Source = target;
            }
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM