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

Add 16 bit png support #613

Merged
merged 38 commits into from
Jun 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e9ddf0f
Refactor Rgba64
JimBobSquarePants Jun 12, 2018
4534537
Add Rgba64 methods to IPixel. Touch #610
JimBobSquarePants Jun 12, 2018
e349d4b
Read Rgba64 png + some tests
JimBobSquarePants Jun 13, 2018
88cb242
Add some TODOs
JimBobSquarePants Jun 13, 2018
7c72ea5
Fix ImageMaths change.
JimBobSquarePants Jun 14, 2018
fa4226a
Fix conversion add conversion tests
JimBobSquarePants Jun 14, 2018
2ad603a
Minor cleanup
JimBobSquarePants Jun 15, 2018
c4646b6
Add Rgb48
JimBobSquarePants Jun 15, 2018
6ea2962
Rgba48 => Rgb48
JimBobSquarePants Jun 15, 2018
332dd70
Add Rgb48 tests
JimBobSquarePants Jun 15, 2018
2a7bde5
Fix tests
JimBobSquarePants Jun 15, 2018
3049324
Add IPixel Rgb48 methods
JimBobSquarePants Jun 15, 2018
aee4778
Use Rgb48 for 16 bit png decoding.
JimBobSquarePants Jun 15, 2018
97012b9
Can now decode all bit depths.
JimBobSquarePants Jun 15, 2018
0e9efdf
Fix alpha8 conversion.
JimBobSquarePants Jun 15, 2018
7ee6f7a
Really fix Alpha conversion
JimBobSquarePants Jun 15, 2018
4baaddf
Add Rgb48 tests
JimBobSquarePants Jun 16, 2018
f8deb06
Add pixel operation tests
JimBobSquarePants Jun 17, 2018
933ceb9
Merge branch 'master' into js/16-bit-pngs
JimBobSquarePants Jun 17, 2018
bb29ff9
Can now encode 16bit pngs.
JimBobSquarePants Jun 17, 2018
8492656
Update submodule from master.
JimBobSquarePants Jun 17, 2018
a23bf45
Merge branch 'master' into js/16-bit-pngs
JimBobSquarePants Jun 17, 2018
8628aaa
Add 16bit decoder tests.
JimBobSquarePants Jun 18, 2018
49a5745
All tests now pass
JimBobSquarePants Jun 18, 2018
1d8c239
Remove allocation when upscaling.
JimBobSquarePants Jun 18, 2018
973000f
Use Rgba64 for image comparison.
JimBobSquarePants Jun 18, 2018
2d6eafa
Use tolerant comparer.
JimBobSquarePants Jun 18, 2018
692c92c
Merge branch 'master' into js/16-bit-pngs
antonfirsov Jun 18, 2018
34d1441
Use SD, Better conversion and cleanup SD Bridge.
JimBobSquarePants Jun 19, 2018
6d415b5
Lol Whut?
JimBobSquarePants Jun 19, 2018
d52a7b2
Merge branch 'master' into js/16-bit-pngs
antonfirsov Jun 19, 2018
4eb8617
Faster 32-64 bit conversion, update references, and cleanup.
JimBobSquarePants Jun 21, 2018
5da4184
Better tRNS coverage
JimBobSquarePants Jun 21, 2018
922d367
More tests
JimBobSquarePants Jun 21, 2018
5672964
Merge branch 'master' into js/16-bit-pngs
JimBobSquarePants Jun 22, 2018
fe3b473
Merge branch 'master' into js/16-bit-pngs
JimBobSquarePants Jun 22, 2018
76a6819
Merge branch 'master' into js/16-bit-pngs
JimBobSquarePants Jun 23, 2018
46df59f
Merge branch 'master' into js/16-bit-pngs
JimBobSquarePants Jun 23, 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
2 changes: 1 addition & 1 deletion src/ImageSharp/Common/Helpers/ImageMaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static int FastAbs(int x)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetBitsNeededForColorDepth(int colors)
{
return (int)Math.Ceiling(Math.Log(colors, 2));
return Math.Max(1, (int)Math.Ceiling(Math.Log(colors, 2)));
}

/// <summary>
Expand Down
14 changes: 10 additions & 4 deletions src/ImageSharp/Formats/Png/IPngEncoderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ namespace SixLabors.ImageSharp.Formats.Png
internal interface IPngEncoderOptions
{
/// <summary>
/// Gets the png color type
/// Gets the number of bits per sample or per palette index (not per pixel).
/// Not all values are allowed for all <see cref="ColorType"/> values.
/// </summary>
PngColorType PngColorType { get; }
PngBitDepth BitDepth { get; }

/// <summary>
/// Gets the png filter method.
/// Gets the color type
/// </summary>
PngFilterMethod PngFilterMethod { get; }
PngColorType ColorType { get; }

/// <summary>
/// Gets the filter method.
/// </summary>
PngFilterMethod FilterMethod { get; }

/// <summary>
/// Gets the compression level 1-9.
Expand Down
22 changes: 22 additions & 0 deletions src/ImageSharp/Formats/Png/PngBitDepth.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

// Note the value assignment, This will allow us to add 1, 2, and 4 bit encoding when we support it.
namespace SixLabors.ImageSharp.Formats.Png
{
/// <summary>
/// Provides enumeration for the available PNG bit depths.
/// </summary>
public enum PngBitDepth
{
/// <summary>
/// 8 bits per sample or per palette index (not per pixel).
/// </summary>
Bit8 = 8,

/// <summary>
/// 16 bits per sample or per palette index (not per pixel).
/// </summary>
Bit16 = 16
}
}
8 changes: 4 additions & 4 deletions src/ImageSharp/Formats/Png/PngConfigurationModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace SixLabors.ImageSharp.Formats.Png
public sealed class PngConfigurationModule : IConfigurationModule
{
/// <inheritdoc/>
public void Configure(Configuration config)
public void Configure(Configuration configuration)
{
config.ImageFormatsManager.SetEncoder(ImageFormats.Png, new PngEncoder());
config.ImageFormatsManager.SetDecoder(ImageFormats.Png, new PngDecoder());
config.ImageFormatsManager.AddImageFormatDetector(new PngImageFormatDetector());
configuration.ImageFormatsManager.SetEncoder(ImageFormats.Png, new PngEncoder());
configuration.ImageFormatsManager.SetDecoder(ImageFormats.Png, new PngDecoder());
configuration.ImageFormatsManager.AddImageFormatDetector(new PngImageFormatDetector());
}
}
}
Loading