@@ -70,7 +70,7 @@ public BmpInfoHeader(
7070 int width ,
7171 int height ,
7272 short planes ,
73- short bitsPerPixel ,
73+ ushort bitsPerPixel ,
7474 BmpCompression compression = default ,
7575 int imageSize = 0 ,
7676 int xPelsPerMeter = 0 ,
@@ -157,7 +157,7 @@ public BmpInfoHeader(
157157 /// Gets or sets the number of bits per pixel, which is the color depth of the image.
158158 /// Typical values are 1, 4, 8, 16, 24 and 32.
159159 /// </summary>
160- public short BitsPerPixel { get ; set ; }
160+ public ushort BitsPerPixel { get ; set ; }
161161
162162 /// <summary>
163163 /// Gets or sets the compression method being used.
@@ -311,7 +311,7 @@ public BmpInfoHeader(
311311 width : BinaryPrimitives . ReadUInt16LittleEndian ( data . Slice ( 4 , 2 ) ) ,
312312 height : BinaryPrimitives . ReadUInt16LittleEndian ( data . Slice ( 6 , 2 ) ) ,
313313 planes : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 8 , 2 ) ) ,
314- bitsPerPixel : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 10 , 2 ) ) ) ;
314+ bitsPerPixel : BinaryPrimitives . ReadUInt16LittleEndian ( data . Slice ( 10 , 2 ) ) ) ;
315315
316316 /// <summary>
317317 /// Parses a short variant of the OS22XBITMAPHEADER. It is identical to the BITMAPCOREHEADER, except that the width and height
@@ -325,7 +325,7 @@ public BmpInfoHeader(
325325 width : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 4 , 4 ) ) ,
326326 height : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 8 , 4 ) ) ,
327327 planes : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 12 , 2 ) ) ,
328- bitsPerPixel : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ) ;
328+ bitsPerPixel : BinaryPrimitives . ReadUInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ) ;
329329
330330 /// <summary>
331331 /// Parses the full BMP Version 3 BITMAPINFOHEADER header (40 bytes).
@@ -338,7 +338,7 @@ public BmpInfoHeader(
338338 width : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 4 , 4 ) ) ,
339339 height : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 8 , 4 ) ) ,
340340 planes : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 12 , 2 ) ) ,
341- bitsPerPixel : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ,
341+ bitsPerPixel : BinaryPrimitives . ReadUInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ,
342342 compression : ( BmpCompression ) BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 16 , 4 ) ) ,
343343 imageSize : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 20 , 4 ) ) ,
344344 xPelsPerMeter : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 24 , 4 ) ) ,
@@ -359,7 +359,7 @@ public BmpInfoHeader(
359359 width : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 4 , 4 ) ) ,
360360 height : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 8 , 4 ) ) ,
361361 planes : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 12 , 2 ) ) ,
362- bitsPerPixel : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ,
362+ bitsPerPixel : BinaryPrimitives . ReadUInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ,
363363 compression : ( BmpCompression ) BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 16 , 4 ) ) ,
364364 imageSize : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 20 , 4 ) ) ,
365365 xPelsPerMeter : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 24 , 4 ) ) ,
@@ -386,7 +386,7 @@ public static BmpInfoHeader ParseOs2Version2(ReadOnlySpan<byte> data)
386386 width : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 4 , 4 ) ) ,
387387 height : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 8 , 4 ) ) ,
388388 planes : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 12 , 2 ) ) ,
389- bitsPerPixel : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ) ;
389+ bitsPerPixel : BinaryPrimitives . ReadUInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ) ;
390390
391391 // The compression value in OS/2 bitmap has a different meaning than in windows bitmaps.
392392 // Map the OS/2 value to the windows values.
@@ -431,7 +431,7 @@ public static BmpInfoHeader ParseOs2Version2(ReadOnlySpan<byte> data)
431431 width : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 4 , 4 ) ) ,
432432 height : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 8 , 4 ) ) ,
433433 planes : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 12 , 2 ) ) ,
434- bitsPerPixel : BinaryPrimitives . ReadInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ,
434+ bitsPerPixel : BinaryPrimitives . ReadUInt16LittleEndian ( data . Slice ( 14 , 2 ) ) ,
435435 compression : ( BmpCompression ) BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 16 , 4 ) ) ,
436436 imageSize : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 20 , 4 ) ) ,
437437 xPelsPerMeter : BinaryPrimitives . ReadInt32LittleEndian ( data . Slice ( 24 , 4 ) ) ,
@@ -484,7 +484,7 @@ public void WriteV3Header(Span<byte> buffer)
484484 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 4 , 4 ) , this . Width ) ;
485485 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 8 , 4 ) , this . Height ) ;
486486 BinaryPrimitives . WriteInt16LittleEndian ( buffer . Slice ( 12 , 2 ) , this . Planes ) ;
487- BinaryPrimitives . WriteInt16LittleEndian ( buffer . Slice ( 14 , 2 ) , this . BitsPerPixel ) ;
487+ BinaryPrimitives . WriteUInt16LittleEndian ( buffer . Slice ( 14 , 2 ) , this . BitsPerPixel ) ;
488488 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 16 , 4 ) , ( int ) this . Compression ) ;
489489 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 20 , 4 ) , this . ImageSize ) ;
490490 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 24 , 4 ) , this . XPelsPerMeter ) ;
@@ -504,7 +504,7 @@ public void WriteV4Header(Span<byte> buffer)
504504 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 4 , 4 ) , this . Width ) ;
505505 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 8 , 4 ) , this . Height ) ;
506506 BinaryPrimitives . WriteInt16LittleEndian ( buffer . Slice ( 12 , 2 ) , this . Planes ) ;
507- BinaryPrimitives . WriteInt16LittleEndian ( buffer . Slice ( 14 , 2 ) , this . BitsPerPixel ) ;
507+ BinaryPrimitives . WriteUInt16LittleEndian ( buffer . Slice ( 14 , 2 ) , this . BitsPerPixel ) ;
508508 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 16 , 4 ) , ( int ) this . Compression ) ;
509509 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 20 , 4 ) , this . ImageSize ) ;
510510 BinaryPrimitives . WriteInt32LittleEndian ( buffer . Slice ( 24 , 4 ) , this . XPelsPerMeter ) ;
0 commit comments