积极答复者
如何做才能跨域访问图片?

问题
答案
全部回复
-
不知道你代码怎么写的。 Image控件是可以用的
Code Snippet<Canvas>
<TextBlock>ddd</TextBlock>
<Image Source="http://profile.csdn.net/net_lover/picture/1.jpg" Canvas.Left="20"></Image>
</Canvas>
</Grid>2008年7月7日 14:04 -
nasawz 写: 我做的一个相册 调用http://picasaweb.google.com下的照片数据.
请问如何做才能跨域调用.
picasaweb下也有crossdomain.xml文件.但是好像不太好用.孟大哥说的对,图片不需要跨域,跨域只对 xml webservic wcf 以及动态网站 http post提交返回,socket等起作用
Image控件只是对图片地址进行引用,并不会在SL本地复制存在图片的副本,所以不存在跨域问题。
你如果从其他网站 WebClient Download下这个图片的话再显示那就要跨域问题了,动态添加图片的办法
BitmapImage bitimg = new BitmapImage(new Uri("http://i3.sinaimg.cn/blog/http/you.video.sina.com.cn/b/U2261P478T2D34663F21DT20080707141428.jpg", UriKind.Absolute));
myimg.Source = bi;2008年7月7日 22:58 -
2008年7月8日 0:53
-
代码是这样的
Code SnippetUri uri = new Uri(album.ThumbUrl);
ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri);
xImage.SetValue(Image.SourceProperty, img);其实我想要的是这样. 可以制作图片下载的进度调.
Code Snippet#region 期待ing
//public void LoadCoverImage()
//{
// Uri uri = new Uri(album.ThumbUrl, UriKind.Absolute);
// WebClient client = new WebClient();
// client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
// client.DownloadStringAsync(uri);
//}//void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
//{
// if (e.Error == null)
// {
// BitmapImage bi = new BitmapImage();
// bi.SetSource(e.Result as Stream);
// xImage.Source = bi;
// }
//}
#endregion2008年7月8日 2:49 -
nasawz 写: 代码是这样的
Code SnippetUri uri = new Uri(album.ThumbUrl);
ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri);
xImage.SetValue(Image.SourceProperty, img);其实我想要的是这样. 可以制作图片下载的进度调.
Code Snippet#region 期待ing
//public void LoadCoverImage()
//{
// Uri uri = new Uri(album.ThumbUrl, UriKind.Absolute);
// WebClient client = new WebClient();
// client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
// client.DownloadStringAsync(uri);
//}//void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
//{
// if (e.Error == null)
// {
// BitmapImage bi = new BitmapImage();
// bi.SetSource(e.Result as Stream);
// xImage.Source = bi;
// }
//}
#endregion如果图片再本地 同一域下 这个代码是好用的. 但是现在图片在google的picasaweb. 他的域名下也有crossdomain.xml文件. 但是我一直没有试验成功. 请帮帮我.
说了呀,你用WebClient先把图片读取到本地就要跨域访问的支持了,你直接 BitmapImage myimg = new BitMapImage(new Uri(""));就可以了。Google应该是不会给你的服务器添加域权限的
2008年7月8日 8:30 -
你好 按照你说的我的代码是这样的 你看对不对
Code Snippetpublic Page()
{
InitializeComponent();
Uri uri = new Uri("http://i3.sinaimg.cn/blog/http/you.video.sina.com.cn/b/U2261P478T2D34663F21DT20080707141428.jpg", UriKind.Absolute);
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(uri);
}void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
}
}我得到的 e.Result 是 "".
我又尝试了
Code Snippetpublic Page()
{
InitializeComponent();
Uri uri = new Uri("http://i3.sinaimg.cn/blog/http/you.video.sina.com.cn/b/U2261P478T2D34663F21DT20080707141428.jpg", UriKind.Absolute);
WebClient client = new WebClient();
client.OpenReadCompleted+=new OpenReadCompletedEventHandler(client_OpenReadCompleted);
client.OpenReadAsync(uri);
}void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null)
{
}
}得到的 e.Result 是 null.
不知道怎么才能用WebClient把图片读取倒本地. 我的目的是想制作一个图片加载中显示百分数的进度条.
2008年7月8日 8:43