Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implement Tiff codec #119

Merged
merged 77 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
a74d143
Add initial Tiff codec projects, and TiffGen
Andy-Wilkinson Feb 26, 2017
8cbfc8e
Add Tiff implementation of IImageFormat
Andy-Wilkinson Feb 28, 2017
0196499
Reference ImageSharp (temporary code sharing)
Andy-Wilkinson Mar 2, 2017
4f6c75a
Add stub Tiff encoders/decoders
Andy-Wilkinson Mar 2, 2017
7e3d2c0
Read and validate the TIFF file header.
Andy-Wilkinson Mar 4, 2017
e976a2c
Make Tiff implementation details internal
Andy-Wilkinson Mar 4, 2017
be842dc
Make TiffDecoderCore more unit-testable
Andy-Wilkinson Mar 5, 2017
5e0fc3b
Read raw data from TIFF IFDs
Andy-Wilkinson Mar 5, 2017
e4e2b4c
More comprehensive testing of header checks
Andy-Wilkinson Mar 5, 2017
0534ce0
Read raw bytes for IFD entries
Andy-Wilkinson Mar 6, 2017
e3d7436
Read integer types from TIFF IFDs
Andy-Wilkinson Mar 12, 2017
a637ef4
Read strings from TIFF IFDs
Andy-Wilkinson Mar 12, 2017
fe6d5f6
Read rational numbers from TIFF IFDs
Andy-Wilkinson Mar 13, 2017
6792d88
Use constants for data type sizes
Andy-Wilkinson Mar 13, 2017
90a3dc9
Read floating-point numbers from TIFF IFDs
Andy-Wilkinson Mar 13, 2017
8cec9d6
Add a number of TIFF specific constants/enums
Andy-Wilkinson Mar 14, 2017
1cb02a4
Merge branch 'master' into tiff-codec
Andy-Wilkinson Mar 14, 2017
736019e
Incorporate Tiff codec into new project structure
Andy-Wilkinson Mar 14, 2017
94847e8
Remove unneeded using statements
Andy-Wilkinson Mar 14, 2017
1646c67
Fix many StyleCop warnings!
Andy-Wilkinson Mar 14, 2017
3b51c36
Add documentation to all elements.
Andy-Wilkinson Mar 18, 2017
aef9284
Run TIFF unit tests in CI
Andy-Wilkinson Mar 18, 2017
a874148
Fix project path for CI coverage script
Andy-Wilkinson Mar 18, 2017
c3a980c
Alternatively... Just merge in the TIFF tests
Andy-Wilkinson Mar 20, 2017
c582ecf
Decode TIFF image dimensions.
Andy-Wilkinson Mar 20, 2017
143a73e
Decode TIFF image resolution
Andy-Wilkinson Mar 29, 2017
959a560
Implement image decoding for the most basic TIFF image format.
Andy-Wilkinson Apr 1, 2017
b71a644
Add Image extensions to save TIFF format files
Andy-Wilkinson Apr 1, 2017
2d6a661
Move TIFF internals into own namespace
Andy-Wilkinson Apr 4, 2017
1322e07
Merge branch 'master' into tiff-codec
Andy-Wilkinson Apr 4, 2017
6979a72
Update TIFF codec to new IImageDecoder signature
Andy-Wilkinson Apr 4, 2017
e00ce80
Add support for WhiteIsZero bilevel & 4-bit images
Andy-Wilkinson Apr 14, 2017
2f1379a
Add support for PackBits compression
Andy-Wilkinson Apr 14, 2017
756b8ab
Add support for multi-strip TIFF files
Andy-Wilkinson Apr 14, 2017
2efc1f0
Merge branch 'master' into tiff-codec
Andy-Wilkinson May 15, 2017
b410526
Update namespaces and naming
Andy-Wilkinson May 15, 2017
da4b738
Add default WhiteIsZero implementation
Andy-Wilkinson May 15, 2017
a579df3
Add support for BlackIsZero
Andy-Wilkinson May 15, 2017
d241c19
Add support for pallete color images
Andy-Wilkinson May 16, 2017
64e0e55
Add support for RGB full color images
Andy-Wilkinson May 16, 2017
933f54b
Add optimised implementation for 8-bit RGB images
Andy-Wilkinson May 16, 2017
2147169
Add support for Deflate (and OldDeflate) compression
Andy-Wilkinson May 21, 2017
d1e0cc6
Add support for RGB (planar) pixel formats
Andy-Wilkinson May 25, 2017
40085b2
Add helper function when reading entries with defaults
Andy-Wilkinson May 25, 2017
ee295f2
Merge branch 'master' into tiff-codec
Andy-Wilkinson May 25, 2017
024d268
PixelAccessor needs to be internal in unit tests
Andy-Wilkinson May 25, 2017
96b3e06
Add support for LZW compression
Andy-Wilkinson May 30, 2017
0ae6220
Add TIFF README.md file
Andy-Wilkinson May 31, 2017
70b8207
Add more items to TIFF readme
Andy-Wilkinson May 31, 2017
743801f
Fill TIFF Readme tables with current status.
Andy-Wilkinson Jun 5, 2017
faee97c
Refactor TIFF metadata reading into separate method
Andy-Wilkinson Jun 5, 2017
f986ac7
Read baseline TIFF metadata
Andy-Wilkinson Jun 6, 2017
49867fb
Merge branch 'master' into tiff-codec
Andy-Wilkinson Jun 6, 2017
38a89f1
Use new pixel packing methods
Andy-Wilkinson Jun 6, 2017
0971b9d
Add some TIFF sample images (autogenerated)
Andy-Wilkinson Jun 6, 2017
16319d0
Add TIFF as a default image format
Andy-Wilkinson Jun 6, 2017
cba51ed
Add 'DecodeTiff' benchmark
Andy-Wilkinson Jun 7, 2017
719e6af
Add TiffEncoder and write TIFF header
Andy-Wilkinson Jun 7, 2017
dfaa4cf
Add TIFF IFD encoding
Andy-Wilkinson Jun 19, 2017
afbe283
Write metadata to a TIFF file
Andy-Wilkinson Jun 22, 2017
8be5d3d
Update xUnit version (and fix test warnings)
Andy-Wilkinson Jul 4, 2017
32ab03b
Merge from latest master
Andy-Wilkinson Jul 5, 2017
a3189de
Use new configuration API for TIFF codec
Andy-Wilkinson Jul 5, 2017
5ca5f77
Merge branch 'master' into tiff-codec
JimBobSquarePants Feb 8, 2018
e4bb5e4
Merge branch 'master' into tiff-codec
JimBobSquarePants Feb 9, 2018
affd736
Merge branch 'master' of https://github.com/SixLabors/ImageSharp into…
JimBobSquarePants Mar 4, 2018
64094c5
Update codebase to catch up with changes to main repo.
JimBobSquarePants Mar 4, 2018
5fa27fb
Use environment specific newline in test
JimBobSquarePants Mar 4, 2018
3bd7f72
Merge branch 'master' into tiff-codec
JimBobSquarePants Mar 4, 2018
6b212c6
Merge branch 'master' of https://github.com/SixLabors/ImageSharp into…
JimBobSquarePants Mar 14, 2018
554318b
Fix namespace reference in tests
JimBobSquarePants Mar 14, 2018
8a513a5
Merge branch 'master' into tiff-codec
JimBobSquarePants Aug 31, 2018
bc7bafe
Merge remote-tracking branch 'upstream/master' into tiff-codec
JimBobSquarePants Oct 17, 2018
ca00f9b
Update tests/Images/External
JimBobSquarePants Oct 18, 2018
f0ead2d
Merge remote-tracking branch 'upstream/master' into tiff-codec
JimBobSquarePants Dec 6, 2018
baf6239
Update IPixel method calls to match new signatures
JimBobSquarePants Dec 6, 2018
a8d25ef
Update external references
JimBobSquarePants Dec 6, 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: 11 additions & 0 deletions src/ImageSharp.Formats.Tiff/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// <copyright file="AssemblyInfo.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>

using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;

// Ensure the internals can be tested.
[assembly: InternalsVisibleTo("ImageSharp.Formats.Tiff.Tests")]
14 changes: 14 additions & 0 deletions src/ImageSharp.Formats.Tiff/ITiffEncoderOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// <copyright file="ITiffEncoderOptions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>

namespace ImageSharp.Formats
{
/// <summary>
/// Encapsulates the options for the <see cref="TiffEncoder"/>.
/// </summary>
public interface ITiffEncoderOptions : IEncoderOptions
{
}
}
19 changes: 19 additions & 0 deletions src/ImageSharp.Formats.Tiff/ImageSharp.Formats.Tiff.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.0.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.1.1" />
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.0.1" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\ImageSharp\**\*.cs" Exclude="..\ImageSharp\obj\**\*.cs" />
</ItemGroup>

</Project>
65 changes: 65 additions & 0 deletions src/ImageSharp.Formats.Tiff/TiffConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// <copyright file="TiffConstants.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>

namespace ImageSharp.Formats
{
using System.Text;

/// <summary>
/// Defines constants defined in the TIFF specification.
/// </summary>
internal static class TiffConstants
{
/// <summary>
/// Byte order markers for indicating little endian encoding.
/// </summary>
public const byte ByteOrderLittleEndian = 0x49;

/// <summary>
/// Byte order markers for indicating big endian encoding.
/// </summary>
public const byte ByteOrderBigEndian = 0x4D;

/// <summary>
/// Magic number used within the image file header to identify a TIFF format file.
/// </summary>
public const ushort HeaderMagicNumber = 42;

/// <summary>
/// Size (in bytes) of the TIFF file header.
/// </summary>
public const int SizeOfTiffHeader = 8;

/// <summary>
/// Size (in bytes) of each individual TIFF IFD entry
/// </summary>
public const int SizeOfIfdEntry = 12;

/// <summary>
/// Size (in bytes) of the Short and SShort data types
/// </summary>
public const int SizeOfShort = 2;

/// <summary>
/// Size (in bytes) of the Long and SLong data types
/// </summary>
public const int SizeOfLong = 4;

/// <summary>
/// Size (in bytes) of the Rational and SRational data types
/// </summary>
public const int SizeOfRational = 8;

/// <summary>
/// Size (in bytes) of the Float data type
/// </summary>
public const int SizeOfFloat = 4;

/// <summary>
/// Size (in bytes) of the Double data type
/// </summary>
public const int SizeOfDouble = 8;
}
}
29 changes: 29 additions & 0 deletions src/ImageSharp.Formats.Tiff/TiffDecoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// <copyright file="TiffDecoder.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>

namespace ImageSharp.Formats
{
using System;
using System.IO;

/// <summary>
/// Image decoder for generating an image out of a TIFF stream.
/// </summary>
public class TiffDecoder : IImageDecoder
{
/// <inheritdoc/>
public void Decode<TColor>(Image<TColor> image, Stream stream, IDecoderOptions options)
where TColor : struct, IPixel<TColor>
{
Guard.NotNull(image, "image");
Guard.NotNull(stream, "stream");

using (TiffDecoderCore decoder = new TiffDecoderCore(options))
{
decoder.Decode(image, stream, false);
}
}
}
}
Loading