//获取验证码 public async Task <ImageSource> GetCheckCode(Service.HttpBaseService _httpService) { Stream stream = null; try { stream = await _httpService.SendRequstForStream(checkCodeUri, HttpMethod.Get); stream.Seek(0, SeekOrigin.Begin); byte[] byteBuffer = new byte[stream.Length]; await stream.ReadAsync(byteBuffer, 0, byteBuffer.Length); var source = await Helper.ImageTool.SaveToImageSource(byteBuffer); return(source); //BitmapImage bitmap = new BitmapImage(); ////using (MemoryStream mem=new MemoryStream()) ////{ //// await stream.CopyToAsync(mem); //// var ras=mem.AsRandomAccessStream(); //// bitmap.SetSource(ras); ////} //await bitmap.SetSourceAsync(stream.AsRandomAccessStream()); //CheckCodeSource = bitmap; } catch { return(null); } }
public async Task <Model.CampusCardInfoModel> GetCampusCardBasicInfo(Service.HttpBaseService _httpService) { var re = await _httpService.SendRequst(cardBasicInfoUri, HttpMethod.Get); var info = PraseCampusCardBasicInfo(re); using (var stream = await _httpService.SendRequstForStream(personImageUri, HttpMethod.Get)) { stream.Seek(0, SeekOrigin.Begin); using (var ras = stream.AsRandomAccessStream()) { WriteableBitmap bitmap = new WriteableBitmap(1, 1); bitmap.SetSource(ras); info.PersonImage = bitmap; } } return(info); }