Skip to content

Commit fccd5b5

Browse files
committed
Remove unused variables
1 parent 802e275 commit fccd5b5

2 files changed

Lines changed: 13 additions & 30 deletions

File tree

src/ImageSharp/Formats/Exr/ExrDecoderCore.cs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/ImageSharp/Formats/Exr/ExrEncoderCore.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken
122122

123123
// Next is offsets table to each pixel row, which will be written after the pixel data was written.
124124
int bytesPerChannel = this.pixelType == ExrPixelType.Half ? 2 : 4;
125-
int numberOfChannels = 3;
126-
uint rowSizeBytes = (uint)(width * numberOfChannels * bytesPerChannel);
127125
ulong startOfRowOffsetData = (ulong)stream.Position;
128126
stream.Position += 8 * height;
129127

@@ -162,7 +160,6 @@ private ulong[] EncodeFloatingPointPixelData<TPixel>(
162160
uint bytesPerRow = ExrUtils.CalculateBytesPerRow(channels, (uint)width);
163161
uint rowsPerBlock = ExrUtils.RowsPerBlock(compression);
164162
uint bytesPerBlock = bytesPerRow * rowsPerBlock;
165-
int channelCount = channels.Count;
166163

167164
using IMemoryOwner<float> rgbBuffer = this.memoryAllocator.Allocate<float>(width * 3, AllocationOptions.Clean);
168165
using IMemoryOwner<byte> rowBlockBuffer = this.memoryAllocator.Allocate<byte>((int)bytesPerBlock, AllocationOptions.Clean);

0 commit comments

Comments
 (0)