Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ImageSharp/Common/Helpers/UnitConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0.

using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;

namespace SixLabors.ImageSharp.Common.Helpers
{
Expand Down
26 changes: 13 additions & 13 deletions src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Common.Helpers;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Memory;

Expand Down Expand Up @@ -66,12 +66,12 @@ internal sealed class BmpDecoderCore
/// <summary>
/// The metadata.
/// </summary>
private ImageMetaData metaData;
private ImageMetadata metadata;

/// <summary>
/// The bmp specific metadata.
/// </summary>
private BmpMetaData bmpMetaData;
private BmpMetadata bmpMetadata;

/// <summary>
/// The file header containing general information.
Expand Down Expand Up @@ -116,7 +116,7 @@ public Image<TPixel> Decode<TPixel>(Stream stream)
{
int bytesPerColorMapEntry = this.ReadImageHeaders(stream, out bool inverted, out byte[] palette);

var image = new Image<TPixel>(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metaData);
var image = new Image<TPixel>(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata);

Buffer2D<TPixel> pixels = image.GetRootFramePixelBuffer();

Expand All @@ -125,7 +125,7 @@ public Image<TPixel> Decode<TPixel>(Stream stream)
case BmpCompression.RGB:
if (this.infoHeader.BitsPerPixel == 32)
{
if (this.bmpMetaData.InfoHeaderType == BmpInfoHeaderType.WinVersion3)
if (this.bmpMetadata.InfoHeaderType == BmpInfoHeaderType.WinVersion3)
{
this.ReadRgb32Slow(pixels, this.infoHeader.Width, this.infoHeader.Height, inverted);
}
Expand Down Expand Up @@ -188,7 +188,7 @@ public Image<TPixel> Decode<TPixel>(Stream stream)
public IImageInfo Identify(Stream stream)
{
this.ReadImageHeaders(stream, out _, out _);
return new ImageInfo(new PixelTypeInfo(this.infoHeader.BitsPerPixel), this.infoHeader.Width, this.infoHeader.Height, this.metaData);
return new ImageInfo(new PixelTypeInfo(this.infoHeader.BitsPerPixel), this.infoHeader.Width, this.infoHeader.Height, this.metadata);
}

/// <summary>
Expand Down Expand Up @@ -999,7 +999,7 @@ private void ReadInfoHeader()
}

// Resolution is stored in PPM.
var meta = new ImageMetaData
var meta = new ImageMetadata
{
ResolutionUnits = PixelResolutionUnit.PixelsPerMeter
};
Expand All @@ -1011,21 +1011,21 @@ private void ReadInfoHeader()
else
{
// Convert default metadata values to PPM.
meta.HorizontalResolution = Math.Round(UnitConverter.InchToMeter(ImageMetaData.DefaultHorizontalResolution));
meta.VerticalResolution = Math.Round(UnitConverter.InchToMeter(ImageMetaData.DefaultVerticalResolution));
meta.HorizontalResolution = Math.Round(UnitConverter.InchToMeter(ImageMetadata.DefaultHorizontalResolution));
meta.VerticalResolution = Math.Round(UnitConverter.InchToMeter(ImageMetadata.DefaultVerticalResolution));
}

this.metaData = meta;
this.metadata = meta;

short bitsPerPixel = this.infoHeader.BitsPerPixel;
this.bmpMetaData = this.metaData.GetFormatMetaData(BmpFormat.Instance);
this.bmpMetaData.InfoHeaderType = infoHeaderType;
this.bmpMetadata = this.metadata.GetFormatMetadata(BmpFormat.Instance);
this.bmpMetadata.InfoHeaderType = infoHeaderType;

// We can only encode at these bit rates so far.
if (bitsPerPixel.Equals((short)BmpBitsPerPixel.Pixel24)
|| bitsPerPixel.Equals((short)BmpBitsPerPixel.Pixel32))
{
this.bmpMetaData.BitsPerPixel = (BmpBitsPerPixel)bitsPerPixel;
this.bmpMetadata.BitsPerPixel = (BmpBitsPerPixel)bitsPerPixel;
}

// skip the remaining header because we can't read those parts
Expand Down
26 changes: 13 additions & 13 deletions src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Common.Helpers;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Memory;

Expand Down Expand Up @@ -73,9 +73,9 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
Guard.NotNull(stream, nameof(stream));

this.configuration = image.GetConfiguration();
ImageMetaData metaData = image.MetaData;
BmpMetaData bmpMetaData = metaData.GetFormatMetaData(BmpFormat.Instance);
this.bitsPerPixel = this.bitsPerPixel ?? bmpMetaData.BitsPerPixel;
ImageMetadata metadata = image.Metadata;
BmpMetadata bmpMetadata = metadata.GetFormatMetadata(BmpFormat.Instance);
this.bitsPerPixel = this.bitsPerPixel ?? bmpMetadata.BitsPerPixel;

short bpp = (short)this.bitsPerPixel;
int bytesPerLine = 4 * (((image.Width * bpp) + 31) / 32);
Expand All @@ -85,27 +85,27 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
int hResolution = 0;
int vResolution = 0;

if (metaData.ResolutionUnits != PixelResolutionUnit.AspectRatio)
if (metadata.ResolutionUnits != PixelResolutionUnit.AspectRatio)
{
if (metaData.HorizontalResolution > 0 && metaData.VerticalResolution > 0)
if (metadata.HorizontalResolution > 0 && metadata.VerticalResolution > 0)
{
switch (metaData.ResolutionUnits)
switch (metadata.ResolutionUnits)
{
case PixelResolutionUnit.PixelsPerInch:

hResolution = (int)Math.Round(UnitConverter.InchToMeter(metaData.HorizontalResolution));
vResolution = (int)Math.Round(UnitConverter.InchToMeter(metaData.VerticalResolution));
hResolution = (int)Math.Round(UnitConverter.InchToMeter(metadata.HorizontalResolution));
vResolution = (int)Math.Round(UnitConverter.InchToMeter(metadata.VerticalResolution));
break;

case PixelResolutionUnit.PixelsPerCentimeter:

hResolution = (int)Math.Round(UnitConverter.CmToMeter(metaData.HorizontalResolution));
vResolution = (int)Math.Round(UnitConverter.CmToMeter(metaData.VerticalResolution));
hResolution = (int)Math.Round(UnitConverter.CmToMeter(metadata.HorizontalResolution));
vResolution = (int)Math.Round(UnitConverter.CmToMeter(metadata.VerticalResolution));
break;

case PixelResolutionUnit.PixelsPerMeter:
hResolution = (int)Math.Round(metaData.HorizontalResolution);
vResolution = (int)Math.Round(metaData.VerticalResolution);
hResolution = (int)Math.Round(metadata.HorizontalResolution);
vResolution = (int)Math.Round(metadata.VerticalResolution);

break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Bmp/BmpFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <summary>
/// Registers the image encoders, decoders and mime type detectors for the bmp format.
/// </summary>
public sealed class BmpFormat : IImageFormat<BmpMetaData>
public sealed class BmpFormat : IImageFormat<BmpMetadata>
{
private BmpFormat()
{
Expand All @@ -32,6 +32,6 @@ private BmpFormat()
public IEnumerable<string> FileExtensions => BmpConstants.FileExtensions;

/// <inheritdoc/>
public BmpMetaData CreateDefaultFormatMetaData() => new BmpMetaData();
public BmpMetadata CreateDefaultFormatMetadata() => new BmpMetadata();
}
}
12 changes: 6 additions & 6 deletions src/ImageSharp/Formats/Bmp/BmpMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// <summary>
/// Provides Bmp specific metadata information for the image.
/// </summary>
public class BmpMetaData : IDeepCloneable
public class BmpMetadata : IDeepCloneable
{
/// <summary>
/// Initializes a new instance of the <see cref="BmpMetaData"/> class.
/// Initializes a new instance of the <see cref="BmpMetadata"/> class.
/// </summary>
public BmpMetaData()
public BmpMetadata()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BmpMetaData"/> class.
/// Initializes a new instance of the <see cref="BmpMetadata"/> class.
/// </summary>
/// <param name="other">The metadata to create an instance from.</param>
private BmpMetaData(BmpMetaData other)
private BmpMetadata(BmpMetadata other)
{
this.BitsPerPixel = other.BitsPerPixel;
this.InfoHeaderType = other.InfoHeaderType;
Expand All @@ -36,7 +36,7 @@ private BmpMetaData(BmpMetaData other)
public BmpBitsPerPixel BitsPerPixel { get; set; } = BmpBitsPerPixel.Pixel24;

/// <inheritdoc/>
public IDeepCloneable DeepClone() => new BmpMetaData(this);
public IDeepCloneable DeepClone() => new BmpMetadata(this);

// TODO: Colors used once we support encoding palette bmps.
}
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Formats/Gif/GifDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.IO;
using System.Text;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;

namespace SixLabors.ImageSharp.Formats.Gif
Expand Down
34 changes: 17 additions & 17 deletions src/ImageSharp/Formats/Gif/GifDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Text;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Memory;
using SixLabors.Primitives;
Expand Down Expand Up @@ -63,12 +63,12 @@ internal sealed class GifDecoderCore
/// <summary>
/// The abstract metadata.
/// </summary>
private ImageMetaData metaData;
private ImageMetadata metadata;

/// <summary>
/// The gif specific metadata.
/// </summary>
private GifMetaData gifMetaData;
private GifMetadata gifMetadata;

/// <summary>
/// Initializes a new instance of the <see cref="GifDecoderCore"/> class.
Expand Down Expand Up @@ -223,7 +223,7 @@ public IImageInfo Identify(Stream stream)
new PixelTypeInfo(this.logicalScreenDescriptor.BitsPerPixel),
this.logicalScreenDescriptor.Width,
this.logicalScreenDescriptor.Height,
this.metaData);
this.metadata);
}

/// <summary>
Expand Down Expand Up @@ -276,7 +276,7 @@ private void ReadApplicationExtension()
if (subBlockSize == GifConstants.NetscapeLoopingSubBlockSize)
{
this.stream.Read(this.buffer, 0, GifConstants.NetscapeLoopingSubBlockSize);
this.gifMetaData.RepeatCount = GifNetscapeLoopingApplicationExtension.Parse(this.buffer.AsSpan(1)).RepeatCount;
this.gifMetadata.RepeatCount = GifNetscapeLoopingApplicationExtension.Parse(this.buffer.AsSpan(1)).RepeatCount;
this.stream.Skip(1); // Skip the terminator.
return;
}
Expand Down Expand Up @@ -334,7 +334,7 @@ private void ReadComments()
{
this.stream.Read(commentsBuffer.Array, 0, length);
string comments = this.TextEncoding.GetString(commentsBuffer.Array, 0, length);
this.metaData.Properties.Add(new ImageProperty(GifConstants.Comments, comments));
this.metadata.Properties.Add(new ImageProperty(GifConstants.Comments, comments));
}
}
}
Expand Down Expand Up @@ -416,9 +416,9 @@ private void ReadFrameColors<TPixel>(ref Image<TPixel> image, ref ImageFrame<TPi
if (previousFrame is null)
{
// This initializes the image to become fully transparent because the alpha channel is zero.
image = new Image<TPixel>(this.configuration, imageWidth, imageHeight, this.metaData);
image = new Image<TPixel>(this.configuration, imageWidth, imageHeight, this.metadata);

this.SetFrameMetaData(image.Frames.RootFrame.MetaData);
this.SetFrameMetadata(image.Frames.RootFrame.Metadata);

imageFrame = image.Frames.RootFrame;
}
Expand All @@ -431,7 +431,7 @@ private void ReadFrameColors<TPixel>(ref Image<TPixel> image, ref ImageFrame<TPi

currentFrame = image.Frames.AddFrame(previousFrame); // This clones the frame and adds it the collection

this.SetFrameMetaData(currentFrame.MetaData);
this.SetFrameMetadata(currentFrame.Metadata);

imageFrame = currentFrame;

Expand Down Expand Up @@ -549,11 +549,11 @@ private void RestoreToBackground<TPixel>(ImageFrame<TPixel> frame)
/// <summary>
/// Sets the frames metadata.
/// </summary>
/// <param name="meta">The meta data.</param>
/// <param name="meta">The metadata.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void SetFrameMetaData(ImageFrameMetaData meta)
private void SetFrameMetadata(ImageFrameMetadata meta)
{
GifFrameMetaData gifMeta = meta.GetFormatMetaData(GifFormat.Instance);
GifFrameMetadata gifMeta = meta.GetFormatMetadata(GifFormat.Instance);
if (this.graphicsControlExtension.DelayTime > 0)
{
gifMeta.FrameDelay = this.graphicsControlExtension.DelayTime;
Expand Down Expand Up @@ -586,7 +586,7 @@ private void ReadLogicalScreenDescriptorAndGlobalColorTable(Stream stream)
this.stream.Skip(6);
this.ReadLogicalScreenDescriptor();

var meta = new ImageMetaData();
var meta = new ImageMetadata();

// The Pixel Aspect Ratio is defined to be the quotient of the pixel's
// width over its height. The value range in this field allows
Expand Down Expand Up @@ -614,16 +614,16 @@ private void ReadLogicalScreenDescriptorAndGlobalColorTable(Stream stream)
}
}

this.metaData = meta;
this.gifMetaData = meta.GetFormatMetaData(GifFormat.Instance);
this.gifMetaData.ColorTableMode = this.logicalScreenDescriptor.GlobalColorTableFlag
this.metadata = meta;
this.gifMetadata = meta.GetFormatMetadata(GifFormat.Instance);
this.gifMetadata.ColorTableMode = this.logicalScreenDescriptor.GlobalColorTableFlag
? GifColorTableMode.Global
: GifColorTableMode.Local;

if (this.logicalScreenDescriptor.GlobalColorTableFlag)
{
int globalColorTableLength = this.logicalScreenDescriptor.GlobalColorTableSize * 3;
this.gifMetaData.GlobalColorTableLength = globalColorTableLength;
this.gifMetadata.GlobalColorTableLength = globalColorTableLength;

this.globalColorTable = this.MemoryAllocator.AllocateManagedByteBuffer(globalColorTableLength, AllocationOptions.Clean);

Expand Down
Loading