Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从windows应用商店应用程序向wpf中的windows桌面应用程序发送tiff文件?_C#_Wpf_Pdf_Windows Store Apps_Tiff - Fatal编程技术网

C# 如何从windows应用商店应用程序向wpf中的windows桌面应用程序发送tiff文件?

C# 如何从windows应用商店应用程序向wpf中的windows桌面应用程序发送tiff文件?,c#,wpf,pdf,windows-store-apps,tiff,C#,Wpf,Pdf,Windows Store Apps,Tiff,我有一个用c#编写的windows应用商店应用程序(8.1),它使用MS pdf API打开一个pdf文件 对pdf进行一些注释后,该文件被编码为tiff文件 pdf文件使用几个wpf画布(每页一个)呈现 这些画布稍后进行渲染,并将其像素编码到tiff文件中 有关守则: private async void CreateSaveBitmapAsync(List<Canvas> results) { Client client = new Client("12

我有一个用c#编写的windows应用商店应用程序(8.1),它使用MS pdf API打开一个pdf文件

对pdf进行一些注释后,该文件被编码为tiff文件

pdf文件使用几个wpf画布(每页一个)呈现

这些画布稍后进行渲染,并将其像素编码到tiff文件中

有关守则:

 private async void CreateSaveBitmapAsync(List<Canvas> results)
    {
        Client client = new Client("127.0.0.1", "13000");

        var picker = new FileSavePicker();
        picker.FileTypeChoices.Add("Tiff Image", new string[] { ".tiff" });
        StorageFile file = await picker.PickSaveFileAsync();

        if (file == null)
        {
            return;
        }

        using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
        {
            var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.TiffEncoderId, stream);

            for (int i = 0; i < results.Count; i++)
            {
                Canvas canvas = results[i];

                RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
                await renderTargetBitmap.RenderAsync(canvas);

                if (canvas != null)
                {
                    if (file != null)
                    {
                        var pixels = await renderTargetBitmap.GetPixelsAsync();

                        byte[] bytes = pixels.ToArray();

                        encoder.SetPixelData(BitmapPixelFormat.Bgra8,
                                             BitmapAlphaMode.Ignore,
                                             (uint)canvas.Width, (uint)canvas.Height,
                                             96, 96, bytes);

                        await encoder.GoToNextFrameAsync();
                    }
                }
            }
        }

        client.SendToServer(file);
    }
现在回答我的问题: 1.如何将此tiff文件发送到.net windows应用程序? 我应该以哪种格式发送? 2.我如何在收到发送回tiff文件的数据后对其进行解码?(备注:tiff文件稍后会转换回pdf文件)。

我尝试将文件流作为字节数组发送,也尝试将像素作为字节数组发送。数据已成功发送,但我没有成功将其解码回tiff文件

诸如此类:

public Image byteArrayToImage(byte[] byteArrayIn)
    {
        MemoryStream ms = new MemoryStream(byteArrayIn);
        ms.Write(byteArrayIn, 0, byteArrayIn.Length);

        Image returnImage = Image.FromStream(ms);

        return returnImage;}
Image.FromStream始终在以下情况下失败:

An exception of type 'System.ArgumentException' occurred in System.Drawing.dll but was not handled in user code

Additional information: Parameter is not valid.
请帮忙。。。 谢谢
Adiel.

当你说WPF-你是指WinRT/XAML吗?还要确保选中Hi-Filip,windows应用商店应用程序在windows rt平板电脑上运行,桌面WPF应用程序在windows 8.1上运行。
An exception of type 'System.ArgumentException' occurred in System.Drawing.dll but was not handled in user code

Additional information: Parameter is not valid.