private async Task <ImageSource> LoadImageFromURL(String sUri, EventHandler <ImageSource> UpdateImageEvent) { var threadID = m_IThreading.GetCurrentThreadID().ToString(); System.Diagnostics.Debug.WriteLine(threadID + "LoadImageFromURL"); var source = new UriImageSource { Uri = new Uri(sUri), CachingEnabled = false }; //Stream imageStream = new System.IO.MemoryStream(); var asyncUrlDownload = new AsyncUrlDownload(m_IThreading); var stream = await asyncUrlDownload.DownloadHttpToArray(sUri); //var bmpConverter = new LoadImageFormats(); //processImage.inputImage = bmpConverter.BMPToImage(stream); if (stream.Item1) { ImageProperties imgProp = await GetImageProperties(stream.Item2); //System.Diagnostics.Debug.WriteLine(threadID + "LoadImageFromURL - res {0}x{1} depth {2} compression {3} subComp {4} inSize {5} outSize {6}", // imgProp.width, imgProp.height, imgProp.bitDepth, imgProp.compressionType, imgProp.subCompressionType, imgProp.inSize, imgProp.outRealSize); processImage.inputImage = new InputImage(imgProp.outBuf.pBuf, (int)(imgProp.width * imgProp.bitDepth / 8.0), imgProp.width, imgProp.height, (int)(imgProp.bitDepth / 8.0)); CanExecuteProcess = true; UpdateImageEvent(this, source); } return(source); }
private async Task <ImageSource> LoadImageFromFile(String sUri) { var threadID = m_IThreading.GetCurrentThreadID().ToString(); System.Diagnostics.Debug.WriteLine(threadID + "LoadImageFromURL"); var fileStream = await m_IFileSupport.FileToStream(sUri); ImageFormat format = await m_IImageSupport.GetFormatImageFileAsync(fileStream); ImageSource source = ImageSource.FromStream(() => fileStream); Stream imageStream = new System.IO.MemoryStream(); var asyncUrlDownload = new AsyncUrlDownload(m_IThreading); var streamBMP = await asyncUrlDownload.DownloadHttpToArray(sUri); if (streamBMP.Item1) { var bmpConverter = new LoadImageFormats(); processImage.inputImage = bmpConverter.BMPToImage(streamBMP.Item2); } CanExecuteProcess = true; return(source); }