This is a migrated thread and some comments may be shown as answers.

Resize image from codebehind

1 Answer 63 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Leonard
Top achievements
Rank 1
Leonard asked on 21 Sep 2017, 12:56 PM

Good morning, sorry by my inglish.

I'm trying to resize a image a 40px from XAML's codebehind , something like that:

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var imageEditor = new RadImageEditor();
            var openDialog = new OpenFileDialog
            {
                Multiselect = false,
                Filter = IMAGE_EXTENSION
            };
            if(openDialog.ShowDialog() == true)
            {
                using (FileStream fileStream = openDialog.File.OpenRead())
                {
                    imageEditor.Image = new RadBitmap(fileStream);
                    imageEditor.Image.Resize(40, 40);
                    imgPreview.Source = bitmap;
                }
            }
        }

imgPreview is a Image control.

This code doesn't work, please, can you help me with it?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 26 Sep 2017, 08:49 AM
Hello Leonardo,

The Resize() method of RadBitmap won't modify the current image, but it will create a copy and return it. So, if you want to get the resized image you will need to assign the result from the Resize() method on something. For example:
imageEditor.Image = new RadBitmap(fileStream);
imageEditor.Image = imageEditor.Image.Resize(40, 40);

Regards,
Martin Ivanov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
ImageEditor
Asked by
Leonard
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or