如何获取图片Uri

How to get Image Uri

我在我的 Windows Phone 应用程序中捕获了一张图像,并通过制作流将其复制到来自 canvas 的图像。现在我想让它的 Uri 将它与另一个图像合并。这是我到目前为止所做的

XAML:

<Canvas x:Name="frontCanvas" Margin="373,0,0,0" Grid.RowSpan="2">            
    <Canvas.Background>
        <VideoBrush x:Name="frontBrush" >
            <VideoBrush.RelativeTransform>
                <CompositeTransform x:Name="viewCompositeTransform" 
                  ScaleX="-1" CenterX=".5" CenterY=".5"/>
            </VideoBrush.RelativeTransform>
        </VideoBrush>
    </Canvas.Background>
</Canvas>

<Image Visibility="Collapsed" x:Name="frontImage" Margin="373,0,0,0" Grid.RowSpan="2">
</Image>

C#

void frontCam_CaptureImageAvailable(
      object sender, Microsoft.Devices.ContentReadyEventArgs e)
{ 
    Dispatcher.BeginInvoke(() =>
    {
        BitmapImage bmp2 = new BitmapImage();
        bmp2.SetSource(e.ImageStream);
        frontImage.Source = bmp2;
        frontCanvas.Visibility = Visibility.Collapsed;
        frontImage.Visibility = Visibility.Visible;
        //img2Name = bmp2.UriSource.ToString();
     });
}

如果您在 Image 中显示从相机捕获的图像,则它不会有 URI。您必须将其作为流(或类似流)使用。

要组合图像,请查看 WriteableBitmapEx 库中的 blitting 函数。
或者,如果您只是想为图像添加效果,请尝试 Lumia Imaging SDK.