我试图从ASP.NET Web Api服务绑定图像那里我contorller
public class ImageController : ApiController { public HttpResponseMessage Getimage() { HttpResponseMessage response = new HttpResponseMessage(); response.Content = new StreamContent(new FileStream("FileAddress",FileMode.Open)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); return response; } }
private async void Button_Click(object sender,RoutedEventArgs e) { Uri datauri = new Uri("http://localhost:63606/Api/Image"); var client = new HttpClient(); var datafil = await client.GetAsync(datauri); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get,datauri); HttpResponseMessage response = await client.SendRequestAsync(request,HttpCompletionoption.ResponseHeadersRead); InMemoryRandomAccessstream randomAccessstream = new InMemoryRandomAccessstream(); DataWriter writer = new DataWriter(randomAccessstream.GetoutputStreamAt(0)); }
我不知道该怎么做,我无法在BitmapImage文件中获取图像。
当我们看到kb或mb时,如何确定大小是基于1000还是1024
如何确定哪些Windows驱动器映射到使用WMI的SAN存储设备?
如何在C ++中创build虚拟存储空间?
在Windows 8应用程序中本地保存数据的最佳方法
怎么做:在Windows 8 / 8.1的“音乐”应用程序中的横向菜单
天青本地存储模拟器发出400个错误的请求
试图增加USB寿命
与应用程序一起存储数据的最快方式是什么?
脚本在Windows Server 2003上工作,但在Windows Server 2012上返回错误0x8007000e
第二种方法,如果你想得到许多照片是,你可以在API文件夹中创建新的文件夹,并将其命名为例如PhotoRepository在此文件夹中添加照片,并通过它获得照片URI
private void Button_Click(object sender,RoutedEventArgs e) { Uri datauri = new Uri("http://localhost:63606/PhotoReposytory/"photo name".jpg"); //jpg or other format BitmapImage foto = new BitmapImage(datauri); Image1.source = foto; }
你可以做以下事情
public class ImageController : ApiController { public HttpResponseMessage Getimage() { HttpResponseMessage response = new HttpResponseMessage(); response.Content = new StreamContent(new FileStream("FileAddress",FileMode.Open)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); return response; } }
并在WinRt应用程序中写入以下代码
private async void Button_Click(object sender,RoutedEventArgs e) { Uri datauri = new Uri("Api Uri"); BitmapImage image= new BitmapImage(datauri); // if you want show result in XAML Controls Image1.sourse=image; }
在XAML
<Image x:Name="Image1" HorizontalAlignment="Left" Height="292" Margin="48,413,0" VerticalAlignment="Top" Width="310"/>