Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f8573e3
Add an equivalent for System.Drawing.Image.GetPixelFormatSize() (#258)
Aug 10, 2017
a56893a
merge with master
Aug 14, 2017
1d81aed
fixes on code review
Aug 18, 2017
47454de
sync with upstream
Aug 24, 2017
ebe664c
update packages
Aug 24, 2017
d6a2d40
fix test image filename
Aug 24, 2017
75a89d6
sync with upstream
Sep 26, 2017
93419ab
fix bugs after merge
Sep 26, 2017
4a59c6f
remove duplicates in .csproj files
Sep 26, 2017
e1dcdef
Merge branch 'master' into master
xakep139 Sep 27, 2017
b5855a0
Merge branch 'master' into master
xakep139 Oct 4, 2017
79e2523
Merge branch 'master' into master
xakep139 Oct 6, 2017
d0e802d
Merge branch 'master' into master
xakep139 Oct 9, 2017
d204e88
Merge branch 'master' into master
xakep139 Oct 10, 2017
a44ceb8
merge with upstream
Oct 13, 2017
68af168
Merge branch 'master' of https://github.com/xakep139/ImageSharp
Oct 13, 2017
8ad7769
Merge branch 'master' into master
xakep139 Oct 18, 2017
5fa82af
Merge branch 'master' into master
xakep139 Nov 23, 2017
d2c0338
Merge branch 'master' into master
xakep139 Dec 8, 2017
75efd72
Merge branch 'master' into master
xakep139 Jan 10, 2018
def3d93
Merge branch 'master' into master
xakep139 Jan 17, 2018
a631a64
Added an API to read base image information without decoding it
denisivan0v Jan 17, 2018
52af4e3
Merge branch 'master' of https://github.com/xakep139/ImageSharp
denisivan0v Jan 17, 2018
b435f5e
codestyle fixes
denisivan0v Jan 17, 2018
9f719d5
codestyle fix
denisivan0v Jan 17, 2018
e88e138
bugfix in GifDecoderCore.Identity
denisivan0v Jan 18, 2018
61c9caf
changes on code review
denisivan0v Jan 19, 2018
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
11 changes: 0 additions & 11 deletions src/ImageSharp/Formats/Gif/GifDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,6 @@ public IImage Identify(Stream stream)
{
if (nextFlag == GifConstants.ImageLabel)
{
GifImageDescriptor imageDescriptor = this.ReadImageDescriptor();

// Determine the color table for this frame. If there is a local one, use it otherwise use the global color table.
if (imageDescriptor.LocalColorTableFlag)
{
int length = imageDescriptor.LocalColorTableSize * 3;

// Skip local color table block
this.Skip(length);
}

// Skip image block
this.Skip(0);
}
Expand Down
59 changes: 59 additions & 0 deletions tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@

using System.IO;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System;



public class GeneralFormatTests : FileTestBase
{
[Theory]
Expand Down Expand Up @@ -146,5 +154,56 @@ public void ImageShouldPreservePixelByteOrderWhenSerialized()
}
}
}

[Theory]
[InlineData(10, 10, "png")]
[InlineData(100, 100, "png")]
[InlineData(100, 10, "png")]
[InlineData(10, 100, "png")]
[InlineData(10, 10, "gif")]
[InlineData(100, 100, "gif")]
[InlineData(100, 10, "gif")]
[InlineData(10, 100, "gif")]
[InlineData(10, 10, "bmp")]
[InlineData(100, 100, "bmp")]
[InlineData(100, 10, "bmp")]
[InlineData(10, 100, "bmp")]
[InlineData(10, 10, "jpg")]
[InlineData(100, 100, "jpg")]
[InlineData(100, 10, "jpg")]
[InlineData(10, 100, "jpg")]
public void CanIdentifyImageLoadedFromBytes(int width, int height, string format)
{
using (Image<Rgba32> image = Image.LoadPixelData(new Rgba32[width * height], width, height))
{
using (var memoryStream = new MemoryStream())
{
image.Save(memoryStream, GetEncoder(format));
memoryStream.Position = 0;

var imageInfo = Image.Identify(memoryStream);

Assert.Equal(imageInfo.Width, width);
Assert.Equal(imageInfo.Height, height);
}
}
}

private static IImageEncoder GetEncoder(string format)
{
switch (format)
{
case "png":
return new PngEncoder();
case "gif":
return new GifEncoder();
case "bmp":
return new BmpEncoder();
case "jpg":
return new JpegEncoder();
default:
throw new ArgumentOutOfRangeException(nameof(format), format, null);
}
}
}
}
1 change: 1 addition & 0 deletions tests/ImageSharp.Tests/ImageSharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreCompat.System.Drawing" Version="1.0.0-beta006" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This enables unit tests execution in JetBrains Rider, but it's not necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's keep it then. I want everyone to be able to test the project in their desired IDE.

<PackageReference Include="xunit" Version="2.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
<PackageReference Include="Moq" Version="4.7.137" />
Expand Down