22
33Decode Portable PixMap images in .NET8.
44
5+
6+
7+ ## PixMap Format
8+
9+ ** Header**
10+
11+ ```
12+ P<x>
13+ # comment
14+ <width> <height>
15+ <max>
16+ ```
17+
18+ ** Example**
19+
20+ ```
21+ P6
22+ 640 480
23+ 65535
24+ ```
25+
26+ ** Kinds**
27+
528| Magic Number | Type | Extension | Image Type | Encoding |
629| ------------ | ---- | --------- | ---------- | -------- |
730| P1 | PBM | .pbm | B/W | ASCII |
@@ -11,6 +34,8 @@ Decode Portable PixMap images in .NET8.
1134| P5 | PGM | .pgm | Gray | Binary |
1235| P6 | PPM | .ppm | RGB | Binary |
1336
37+
38+
1439## Usage
1540
1641``` cs
@@ -21,29 +46,33 @@ IPpmImage ppmImage = await PpmImageReader.ReadAsync(@"C:\image.ppm");
2146IImage rawImage = await RawImageReader .ReadAsync ((@" C:\image.raw" , 1920 , 1080 , 12 , 0 );
2247```
2348
24- ## Benchmark [WIP]
2549
26- > BenchmarkDotNet v0 .13 . 12 , Windows 11 (10.0.22621.3007 / 22H2 / 2022Update / SunValley2 )
50+
51+ ## Benchmark
52+
53+ > BenchmarkDotNet v0 .13 . 12 , Windows 11 (10.0.22621.3672 / 22H2 / 2022Update / SunValley2 )
2754> AMD Ryzen 7 PRO 4750GE with Radeon Graphics , 1 CPU , 16 logical and 8 physical cores
28- > .NET SDK 8.0.200 - preview .23624 . 5
29- > [Host ] : .NET 8.0.1 (8.0.123.58001 ), X64 RyuJIT AVX2 [AttachedDebugger ]
30- > DefaultJob : .NET 8.0.1 (8.0.123.58001 ), X64 RyuJIT AVX2
31-
32-
33- | Method | Filename | Mean | Error | StdDev | Median | Gen0 | Gen1 | Gen2 | Allocated |
34- | ---------- | -------------- | ---------- : | -------- - : | -------- : | ---------- : | ------ - : | ------ - : | ------ - : | -------- : |
35- | ReadHeader | P1 - 200x200 .pbm | 78 . 65 us | 0 . 508 us | 0 . 475 us | 78 . 45 us | 4 . 0283 | - | - | 7 . 96 KB |
36- | ReadImage | P1 - 200x200 .pbm | 459 . 96 us | 9 . 005 us | 11 . 709 us | 455 . 43 us | 25 . 3906 | - | - | 51 . 87 KB |
37- | ReadHeader | P2 - 300x200 .pgm | 75 . 32 us | 0 . 255 us | 0 . 226 us | 75 . 34 us | 4 . 0283 | - | - | 7 . 94 KB |
38- | ReadImage | P2 - 300x200 .pgm | 1 ,138 . 71 us | 14 . 674 us | 13 . 726 us | 1 ,140 . 11 us | 35 . 1563 | - | - | 75 . 98 KB |
39- | ReadHeader | P3 - 300x300 .ppm | 78 . 10 us | 0 . 712 us | 0 . 594 us | 78 . 21 us | 4 . 0283 | - | - | 8 . 13 KB |
40- | ReadImage | P3 - 300x300 .ppm | 6 ,935 . 08 us | 104 . 674 us | 97 . 912 us | 6 ,985 . 39 us | 78 . 1250 | 78 . 1250 | 78 . 1250 | 321 . 88 KB |
41- | ReadHeader | P4 - 305x400 .pbm | 77 . 23 us | 1 . 494 us | 1 . 889 us | 76 . 07 us | 3 . 7842 | - | - | 7 . 62 KB |
42- | ReadImage | P4 - 305x400 .pbm | 216 . 83 us | 3 . 972 us | 3 . 521 us | 216 . 33 us | 38 . 0859 | 38 . 0859 | 38 . 0859 | 128 . 74 KB |
43- | ReadHeader | P5 - 300x246 .pgm | 78 . 56 us | 1 . 184 us | 1 . 108 us | 78 . 68 us | 3 . 7842 | - | - | 7 . 76 KB |
44- | ReadImage | P5 - 300x246 .pgm | 123 . 08 us | 2 . 279 us | 2 . 132 us | 122 . 29 us | 41 . 5039 | - | - | 82 . 11 KB |
45- | ReadHeader | P6 - 640x426 .ppm | 79 . 81 us | 0 . 578 us | 0 . 512 us | 79 . 80 us | 3 . 7842 | - | - | 7 . 76 KB |
46- | ReadImage | P6 - 640x426 .ppm | 537 . 06 us | 10 . 726 us | 17 . 624 us | 535 . 36 us | 249 . 0234 | 249 . 0234 | 249 . 0234 | 808 . 97 KB |
55+ > .NET SDK 8.0.300
56+ > [Host ] : .NET 8.0.5 (8.0.524.21615 ), X64 RyuJIT AVX2 [AttachedDebugger ]
57+ > DefaultJob : .NET 8.0.5 (8.0.524.21615 ), X64 RyuJIT AVX2
58+
59+
60+ | Method | Filename | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated |
61+ | ---------- | -------------- | ---------- : | -------- : | -------- : | ------ - : | ------ - : | ------ - : | -------- : |
62+ | ReadHeader | P1 - 200x200 .pbm | 69 . 76 us | 0 . 303 us | 0 . 283 us | 3 . 9063 | - | - | 7 . 46 KB |
63+ | ReadImage | P1 - 200x200 .pbm | 345 . 65 us | 4 . 595 us | 4 . 073 us | 24 . 9023 | - | - | 47 . 38 KB |
64+ | ReadHeader | P2 - 300x200 .pgm | 72 . 01 us | 1 . 324 us | 1 . 238 us | 3 . 9063 | - | - | 7 . 44 KB |
65+ | ReadImage | P2 - 300x200 .pgm | 842 . 29 us | 4 . 745 us | 4 . 439 us | 34 . 1797 | - | - | 67 . 02 KB |
66+ | ReadHeader | P3 - 300x300 .ppm | 69 . 91 us | 0 . 333 us | 0 . 295 us | 3 . 9063 | - | - | 7 . 63 KB |
67+ | ReadImage | P3 - 300x300 .ppm | 5 ,275 . 37 us | 16 . 544 us | 15 . 475 us | 78 . 1250 | 78 . 1250 | 78 . 1250 | 272 . 26 KB |
68+ | ReadHeader | P4 - 305x400 .pbm | 73 . 66 us | 0 . 300 us | 0 . 266 us | 3 . 6621 | - | - | 7 . 12 KB |
69+ | ReadImage | P4 - 305x400 .pbm | 194 . 32 us | 1 . 287 us | 1 . 141 us | 38 . 3301 | 38 . 3301 | 38 . 3301 | 127 . 17 KB |
70+ | ReadHeader | P5 - 300x246 .pgm | 69 . 91 us | 1 . 326 us | 1 . 419 us | 3 . 6621 | - | - | 7 . 26 KB |
71+ | ReadImage | P5 - 300x246 .pgm | 101 . 39 us | 0 . 581 us | 0 . 543 us | 41 . 5039 | - | - | 80 . 3 KB |
72+ | ReadHeader | P6 - 640x426 .ppm | 72 . 04 us | 0 . 450 us | 0 . 399 us | 3 . 6621 | - | - | 7 . 26 KB |
73+ | ReadImage | P6 - 640x426 .ppm | 455 . 97 us | 3 . 875 us | 3 . 625 us | 249 . 5117 | 249 . 5117 | 249 . 5117 | 807 . 15 KB |
74+
75+
4776
4877## References
4978
0 commit comments