Skip to content
Closed
Show file tree
Hide file tree
Changes from 21 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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ solution: ImageSharp.sln

matrix:
include:
- os: linux # Ubuntu 14.04
dist: trusty
- os: linux # Ubuntu 16.04
dist: xenial
sudo: required
dotnet: 2.1.401
dotnet: 2.1.603
mono: latest
# - os: osx # OSX 10.11
# osx_image: xcode7.3.1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ For more examples check out:

If you prefer, you can compile ImageSharp yourself (please do and help!)

- Using [Visual Studio 2017](https://visualstudio.microsoft.com/vs/)
- Using [Visual Studio 2019](https://visualstudio.microsoft.com/vs/)
- Make sure you have the latest version installed
- Make sure you have [the .NET Core 2.1 SDK](https://www.microsoft.com/net/core#windows) installed

Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix>
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix>
<TargetFrameworks>netcoreapp2.1;netstandard1.3;netstandard2.0</TargetFrameworks>
<LangVersion>7.3</LangVersion>
<LangVersion>8.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>SixLabors.ImageSharp.Drawing</AssemblyName>
Expand Down
20 changes: 6 additions & 14 deletions src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,13 @@ public static BmpInfoHeader ParseOs2Version2(ReadOnlySpan<byte> data)

// The compression value in OS/2 bitmap has a different meaning than in windows bitmaps.
// Map the OS/2 value to the windows values.
switch (compression)
infoHeader.Compression = compression switch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn that's nice!

{
case 0:
infoHeader.Compression = BmpCompression.RGB;
break;
case 1:
infoHeader.Compression = BmpCompression.RLE8;
break;
case 2:
infoHeader.Compression = BmpCompression.RLE4;
break;
default:
BmpThrowHelper.ThrowImageFormatException($"Compression type is not supported. ImageSharp only supports uncompressed, RLE4 and RLE8.");
break;
}
0 => BmpCompression.RGB,
1 => BmpCompression.RLE8,
2 => BmpCompression.RLE4,
_ => throw new ImageFormatException($"Compression type is not supported. ImageSharp only supports uncompressed, RLE4 and RLE8.")
};

infoHeader.ImageSize = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(20, 4));
infoHeader.XPelsPerMeter = BinaryPrimitives.ReadInt32LittleEndian(data.Slice(24, 4));
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)

// System.Drawing produces identical output for jpegs with a quality parameter of 0 and 1.
int qlty = (this.quality ?? metadata.GetFormatMetadata(JpegFormat.Instance).Quality).Clamp(1, 100);
this.subsample = this.subsample ?? (qlty >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420);
this.subsample ??= qlty >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420;

// Convert from a quality rating to a scaling factor.
int scale;
Expand Down
20 changes: 10 additions & 10 deletions src/ImageSharp/Formats/Png/Adam7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ internal static class Adam7
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int ComputeColumns(int width, int passIndex)
{
switch (passIndex)
return passIndex switch
{
case 0: return (width + 7) / 8;
case 1: return (width + 3) / 8;
case 2: return (width + 3) / 4;
case 3: return (width + 1) / 4;
case 4: return (width + 1) / 2;
case 5: return width / 2;
case 6: return width;
default: throw new ArgumentException($"Not a valid pass index: {passIndex}");
}
0 => (width + 7) / 8,
1 => (width + 3) / 8,
2 => (width + 3) / 4,
3 => (width + 1) / 4,
4 => (width + 1) / 2,
5 => width / 2,
6 => width,
_ => throw new ArgumentException($"Not a valid pass index: {passIndex}")
};
}
}
}
6 changes: 3 additions & 3 deletions src/ImageSharp/Formats/Png/PngEncoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
// Always take the encoder options over the metadata values.
ImageMetadata metadata = image.Metadata;
PngMetadata pngMetadata = metadata.GetFormatMetadata(PngFormat.Instance);
this.gamma = this.gamma ?? pngMetadata.Gamma;
this.gamma ??= pngMetadata.Gamma;
this.writeGamma = this.gamma > 0;
this.pngColorType = this.pngColorType ?? pngMetadata.ColorType;
this.pngBitDepth = this.pngBitDepth ?? pngMetadata.BitDepth;
this.pngColorType ??= pngMetadata.ColorType;
this.pngBitDepth ??= pngMetadata.BitDepth;
this.use16Bit = this.pngBitDepth == PngBitDepth.Bit16;

// Ensure we are not allowing impossible combinations.
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Image.FromFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static IImageFormat DetectFormat(string filePath)
/// <returns>The mime type or null if none found.</returns>
public static IImageFormat DetectFormat(Configuration config, string filePath)
{
config = config ?? Configuration.Default;
config ??= Configuration.Default;
using (Stream file = config.FileSystem.OpenRead(filePath))
{
return DetectFormat(config, file);
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/Image.FromStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream)
public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
{
config = config ?? Configuration.Default;
config ??= Configuration.Default;
(Image<TPixel> img, IImageFormat format) data = WithSeekableStream(config, stream, s => Decode<TPixel>(s, config));

format = data.format;
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ImageSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<DebugType Condition="$(codecov) == ''">portable</DebugType>
<DebugSymbols>True</DebugSymbols>
<Features>IOperation</Features>
<LangVersion>7.3</LangVersion>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' OR '$(TargetFramework)' == 'net472' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public IccOneDimensionalCurve ReadOneDimensionalCurve()
breakPoints[i] = this.ReadSingle();
}

IccCurveSegment[] segments = new IccCurveSegment[segmentCount];
var segments = new IccCurveSegment[segmentCount];
for (int i = 0; i < segmentCount; i++)
{
segments[i] = this.ReadCurveSegment();
Expand All @@ -47,7 +47,7 @@ public IccResponseCurve ReadResponseCurve(int channelCount)
measurement[i] = this.ReadUInt32();
}

Vector3[] xyzValues = new Vector3[channelCount];
var xyzValues = new Vector3[channelCount];
for (int i = 0; i < channelCount; i++)
{
xyzValues[i] = this.ReadXyzNumber();
Expand All @@ -67,9 +67,9 @@ public IccResponseCurve ReadResponseCurve(int channelCount)
}

/// <summary>
/// Reads a <see cref="IccParametricCurve"/>
/// Reads a <see cref="IccParametricCurve"/>/
/// </summary>
/// <returns>The read curve</returns>
/// <returns>The read curve.</returns>
public IccParametricCurve ReadParametricCurve()
{
ushort type = this.ReadUInt16();
Expand Down Expand Up @@ -104,15 +104,15 @@ public IccParametricCurve ReadParametricCurve()
f = this.ReadFix16();
}

switch (type)
return type switch
{
case 0: return new IccParametricCurve(gamma);
case 1: return new IccParametricCurve(gamma, a, b);
case 2: return new IccParametricCurve(gamma, a, b, c);
case 3: return new IccParametricCurve(gamma, a, b, c, d);
case 4: return new IccParametricCurve(gamma, a, b, c, d, e, f);
default: throw new InvalidIccProfileException($"Invalid parametric curve type of {type}");
}
0 => new IccParametricCurve(gamma),
1 => new IccParametricCurve(gamma, a, b),
2 => new IccParametricCurve(gamma, a, b, c),
3 => new IccParametricCurve(gamma, a, b, c, d),
4 => new IccParametricCurve(gamma, a, b, c, d, e, f),
_ => throw new InvalidIccProfileException($"Invalid parametric curve type of {type}")
};
}

/// <summary>
Expand Down