mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
ImageLoader
This commit is contained in:
parent
61a772d02b
commit
5282046c31
|
|
@ -43,8 +43,12 @@ namespace MapControl
|
|||
internal static async Task<IImage> LoadMergedImageAsync(Uri uri1, Uri uri2, IProgress<double> progress)
|
||||
{
|
||||
WriteableBitmap mergedBitmap = null;
|
||||
var p1 = 0d;
|
||||
var p2 = 0d;
|
||||
|
||||
var images = await LoadImagesAsync(uri1, uri2, progress);
|
||||
var images = await Task.WhenAll(
|
||||
LoadImageAsync(uri1, new Progress<double>(p => { p1 = p; progress.Report((p1 + p2) / 2d); })),
|
||||
LoadImageAsync(uri2, new Progress<double>(p => { p2 = p; progress.Report((p1 + p2) / 2d); })));
|
||||
|
||||
if (images.Length == 2 &&
|
||||
images[0] is Bitmap bitmap1 &&
|
||||
|
|
|
|||
|
|
@ -157,21 +157,5 @@ namespace MapControl
|
|||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static Task<ImageSource[]> LoadImagesAsync(Uri uri1, Uri uri2, IProgress<double> progress)
|
||||
{
|
||||
IProgress<double> progress1 = null;
|
||||
IProgress<double> progress2 = null;
|
||||
|
||||
if (progress != null)
|
||||
{
|
||||
var p1 = 0d;
|
||||
var p2 = 0d;
|
||||
progress1 = new Progress<double>(p => { p1 = p; progress.Report((p1 + p2) / 2d); });
|
||||
progress2 = new Progress<double>(p => { p2 = p; progress.Report((p1 + p2) / 2d); });
|
||||
}
|
||||
|
||||
return Task.WhenAll(LoadImageAsync(uri1, progress1), LoadImageAsync(uri2, progress2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
|
@ -55,8 +56,12 @@ namespace MapControl
|
|||
internal static async Task<ImageSource> LoadMergedImageAsync(Uri uri1, Uri uri2, IProgress<double> progress)
|
||||
{
|
||||
WriteableBitmap mergedBitmap = null;
|
||||
var p1 = 0d;
|
||||
var p2 = 0d;
|
||||
|
||||
var images = await LoadImagesAsync(uri1, uri2, progress);
|
||||
var images = await Task.WhenAll(
|
||||
LoadImageAsync(uri1, new Progress<double>(p => { p1 = p; progress.Report((p1 + p2) / 2d); })),
|
||||
LoadImageAsync(uri2, new Progress<double>(p => { p2 = p; progress.Report((p1 + p2) / 2d); })));
|
||||
|
||||
if (images.Length == 2 &&
|
||||
images[0] is BitmapSource bitmap1 &&
|
||||
|
|
|
|||
Loading…
Reference in a new issue