@@ -92,7 +92,7 @@ private static void WriteSignature(BinaryWriter writer)
92
92
// Bit Depth:
93
93
// 1-byte integer that indicates the number of bits per sample. Valid
94
94
// values depend on the color type used
95
- //
95
+ //
96
96
// -----------------------------------------------
97
97
// | Color Type | Allowed bit depths |
98
98
// -----------------------------------------------
@@ -128,8 +128,8 @@ private static void WriteSignature(BinaryWriter writer)
128
128
//
129
129
// Interlace Method:
130
130
// 1-byte integer that indicates the transmission order of the image
131
- // data.
132
- //
131
+ // data.
132
+ //
133
133
// ---------------------------------------
134
134
// | Interlace Method | Value |
135
135
// ---------------------------------------
@@ -159,7 +159,7 @@ private static void WriteIHDR(BinaryWriter writer, int width, int height)
159
159
// the compression stream.
160
160
//
161
161
// The compression stream is a deflate stream including the Adler-32
162
- // trailer.
162
+ // trailer.
163
163
//
164
164
// Each scanline of the image begins with a single byte that defines the
165
165
// filter used on that scanline.
@@ -215,13 +215,9 @@ void FlushAll(MemoryStream stream)
215
215
216
216
using MemoryStream ms = new ( ) ;
217
217
218
- // Zlib deflate header for Default Compression
219
- ms . WriteByte ( 0x78 ) ;
220
- ms . WriteByte ( 0x9C ) ;
221
-
222
218
Adler32 adler = new ( ) ;
223
219
224
- using ( DeflateStream deflate = new DeflateStream ( ms , CompressionMode . Compress , leaveOpen : true ) )
220
+ using ( ZLibStream deflate = new ZLibStream ( ms , CompressionMode . Compress , leaveOpen : true ) )
225
221
{
226
222
ReadOnlySpan < byte > filter = stackalloc byte [ 1 ] { 0 } ; // Filter mode 0
227
223
for ( int i = 0 ; i < data . Length ; i += width )
@@ -278,7 +274,7 @@ private static void WriteIEND(BinaryWriter writer)
278
274
//
279
275
// If there is no data (Length = 0), then the data chunk is not written
280
276
//
281
- // Length:
277
+ // Length:
282
278
// A 4-byte unsigned integer giving the number of bytes in the chunk's
283
279
// data field. Only the data field. Do not include the length field
284
280
// itself, the chunk type field, or the crc field
@@ -329,12 +325,12 @@ private static void WriteChunk(BinaryWriter writer, string chunkType, ReadOnlySp
329
325
330
326
331
327
// Per https://www.w3.org/TR/png-3/#7Integers-and-byte-order
332
- //
333
- // "All integers that require more than one byte shall be in network
328
+ //
329
+ // "All integers that require more than one byte shall be in network
334
330
// byte order"
335
331
//
336
- // Basically, we have to ensure that all integer type values are in
337
- // BigEndian.
332
+ // Basically, we have to ensure that all integer type values are in
333
+ // BigEndian.
338
334
//
339
335
// This method will check for endianess and convert to BigEndian if needed.
340
336
private static int ToBigEndian ( int value )
0 commit comments