WPF image cropping

Posted by Califer on Stack Overflow See other posts from Stack Overflow or by Califer
Published on 2010-03-23T21:00:05Z Indexed on 2010/03/23 21:03 UTC
Read the original article Hit count: 385

Filed under:
|
|
|

I'm loading layers of images to make a single image. I'm currently stacking them all onto a canvas. I've got it set up so the user can specify the final dimensions of the single image, but even when I change the size of the canvas the images retain their original sizes.

I tried to modify the image size as I was loading them in, but the sizes were NaN and the Actual Sizes were 0 so I couldn't change them there.

I'm starting to think that canvas might not be the way to go. Any suggestions to how I could clip images to fit a specific size?

        canvas1.Children.Clear();
        int totalImages = Window1.GetNumberOfImages();
        if (drawBackground)
            canvas1.Background = new SolidColorBrush(Color.FromArgb(a,r,g,b));
        else
            canvas1.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

        for (int i = 0; i < totalImages; i++)
        {
            Image image = new Image();
            image.Source = Window1.GetNextImage(i);

            canvas1.Children.Add(image);                
        }

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#