-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathDrtBitmapDecoder.cs
More file actions
53 lines (47 loc) · 1.46 KB
/
DrtBitmapDecoder.cs
File metadata and controls
53 lines (47 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace DRT
{
public class DrtBitmapDecoder
{
static int Main(string[] args)
{
var logger = new Logger("DrtBitmapDecoder", "Microsoft",
"Testing decode the image file that created with Asynchronous");
var imageFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Image.png");
using var fileStream = new FileStream(imageFile,
FileMode.Open,
FileAccess.Read,
FileShare.Read,
4096,
FileOptions.Asynchronous);
var passed = false;
try
{
// See https://github.com/dotnet/wpf/issues/4355
_ = BitmapDecoder.Create(fileStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None);
passed = true;
}
catch (ArgumentException)
{
passed = false;
}
if (passed)
{
logger.Log("Passed");
return 0;
}
else
{
logger.Log("ERROR: - DrtBitmapDecoder. Can not decode the async file stream.");
return 1;
}
}
}
}