WPF多点触控和缩放 [英] WPF Multitouch and zooming

查看:552
本文介绍了WPF多点触控和缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个问题:

我有几张图像,将它们放到画布上,订阅了事件ManipulationStarting e ManipulationDelta,到目前为止一切顺利.

我正在从这样的代码后面添加图像:

Hello everybody,

I have just a problem:

I have a few images and I put them into a canvas, subscribing the event ManipulationStarting e ManipulationDelta and so far so good.

I'm adding images from code behind like that :

private void CreateAThumbnail()
        {
            // Create an Image control
            Image thumbnailImage = new Image();
            thumbnailImage.Width = 130;
            thumbnailImage.IsManipulationEnabled = true;

            // Create a BitmapImage and sets its DecodePixelWidth and DecodePixelHeight
            BitmapImage bmpImage = new BitmapImage();
            bmpImage.BeginInit();
            bmpImage.UriSource = new Uri("38-determinazione funzionario resp.tif_page001.tif", UriKind.RelativeOrAbsolute);
 
            thumbnailImage.RenderTransform = new MatrixTransform();
            bmpImage.DecodePixelWidth = 200;
            bmpImage.EndInit();

            // Set Source property of Image
            thumbnailImage.Source = bmpImage;
            canvas.Children.Add(thumbnailImage);

        }

如您所见,我创建了一个BitMapImage并以比原始像素少的像素对其进行解码,因此可以节省内存(实际上我应该加载多达50张图像.tif非常沉重).可以,但同时我想放大 可读的图像,因此我尝试将该图像恢复到其原始像素,以便缩放完全可读.但是我做不到直到现在.

如您所见,我尝试将DecodePixelWidth设置为1200nbsp;在image_ManipulationStarting中,但是图像的像素始终为200.

As you can see, I created a BitMapImage and decoded it with less pixels than the original, so I can save memory (in fact I should load as many as 50 images .tif very heavy).When I zoom the image everything is okay but at the same time I'd like to zoom a readable image, so I tried to restore that image to its original pixel so the zooming would be perfectly readable. But I couldn't do  much until now.

as you see, I tried to set DecodePixelWidth to 1200  in the image_ManipulationStarting but the pixel of image is always 200.

代码在这里:

void image_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
{
    var uie = e.OriginalSource as UIElement;
   

    ImageSource imageSource = ((Image) (uie)).Source;
    BitmapImage bmpToAdjust = imageSource as BitmapImage;

    bmpToAdjust.DecodePixelWidth = 1200;

    //canvas is the parent of the image starting the manipulation;
    //Container does not have to be parent, but that is the most common scenario
    e.ManipulationContainer = canvas;
    e.Handled = true; 
               
}

任何建议将不胜感激!谢谢

Any suggestion would be appreciated! Thanks.

Domenico Mustara

Domenico Mustara

推荐答案

穆斯塔拉,

我们正在处理您的问题,我们将尽快为您提供信息.

We're working on your issue, we will give you information asap.

感谢您的理解和支持.

祝你有美好的一天.


这篇关于WPF多点触控和缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆