@@ -371,30 +371,9 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok
371371 {
372372 ExrHeaderAttributes header = this . ReadExrHeader ( stream ) ;
373373
374- int bitsPerPixel = this . CalculateBitsPerPixel ( ) ;
375-
376374 return new ImageInfo ( new Size ( header . DataWindow . XMax , header . DataWindow . YMax ) , this . metadata ) ;
377375 }
378376
379- private int CalculateBitsPerPixel ( )
380- {
381- int bitsPerPixel = 0 ;
382- for ( int i = 0 ; i < this . Channels . Count ; i ++ )
383- {
384- ExrChannelInfo channel = this . Channels [ 0 ] ;
385- if ( channel . PixelType is ExrPixelType . Float or ExrPixelType . UnsignedInt )
386- {
387- bitsPerPixel += 32 ;
388- }
389- else if ( channel . PixelType == ExrPixelType . Half )
390- {
391- bitsPerPixel += 16 ;
392- }
393- }
394-
395- return bitsPerPixel ;
396- }
397-
398377 private ExrPixelType ValidateChannels ( )
399378 {
400379 if ( this . Channels . Count == 0 )
@@ -475,8 +454,8 @@ private ExrHeaderAttributes ReadExrHeader(BufferedReadStream stream)
475454
476455 // Next three bytes contain info's about the image.
477456 byte flagsByte0 = ( byte ) stream . ReadByte ( ) ;
478- byte flagsByte1 = ( byte ) stream . ReadByte ( ) ;
479- byte flagsByte2 = ( byte ) stream . ReadByte ( ) ;
457+ stream . ReadByte ( ) ;
458+ stream . ReadByte ( ) ;
480459 if ( ( flagsByte0 & ( 1 << 1 ) ) != 0 )
481460 {
482461 ExrThrowHelper . ThrowNotSupported ( "Decoding tiled exr images is not supported yet!" ) ;
@@ -587,6 +566,11 @@ private ExrHeaderAttributes ParseHeaderAttributes(BufferedReadStream stream)
587566 ExrThrowHelper . ThrowInvalidImageContentException ( "Invalid exr image header, the lineOrder attribute is missing!" ) ;
588567 }
589568
569+ if ( ! aspectRatio . HasValue )
570+ {
571+ ExrThrowHelper . ThrowInvalidImageContentException ( "Invalid exr image header, the aspectRatio attribute is missing!" ) ;
572+ }
573+
590574 if ( ! screenWindowWidth . HasValue )
591575 {
592576 ExrThrowHelper . ThrowInvalidImageContentException ( "Invalid exr image header, the screenWindowWidth attribute is missing!" ) ;
@@ -648,7 +632,7 @@ private List<ExrChannelInfo> ReadChannelList(BufferedReadStream stream, int attr
648632 }
649633
650634 // Last byte should be a null byte.
651- int byteRead = stream . ReadByte ( ) ;
635+ stream . ReadByte ( ) ;
652636
653637 return channels ;
654638 }
@@ -662,9 +646,11 @@ private ExrChannelInfo ReadChannelInfo(BufferedReadStream stream, out int bytesR
662646 bytesRead += 4 ;
663647
664648 byte pLinear = ( byte ) stream . ReadByte ( ) ;
665- byte reserved0 = ( byte ) stream . ReadByte ( ) ;
666- byte reserved1 = ( byte ) stream . ReadByte ( ) ;
667- byte reserved2 = ( byte ) stream . ReadByte ( ) ;
649+
650+ // Next 3 bytes are reserved bytes and not use.
651+ stream . ReadByte ( ) ;
652+ stream . ReadByte ( ) ;
653+ stream . ReadByte ( ) ;
668654 bytesRead += 4 ;
669655
670656 int xSampling = this . ReadSignedInteger ( stream ) ;
0 commit comments