Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dc08802
temporarily disable target frameworks
antonfirsov May 17, 2019
f8d1e00
drop DelegateProcessor
antonfirsov May 17, 2019
02f6546
drop IImageProcessingContext<TPixel>
antonfirsov May 17, 2019
cd75b93
drop NamedColors<T>
antonfirsov May 17, 2019
3d7d70b
drop ColorBuilder<T>
antonfirsov May 18, 2019
949386a
drop the *Base postfix for clean class hierarchies
antonfirsov May 18, 2019
68df822
Merge remote-tracking branch 'origin/master' into af/api-cleanup
antonfirsov May 19, 2019
1668f0c
adding basic skeletons
antonfirsov May 19, 2019
6b731aa
non-generic ImageFrameCollection API definition
antonfirsov May 26, 2019
351e806
Merge remote-tracking branch 'origin/master' into af/nongeneric-frame…
antonfirsov Jun 8, 2019
9738924
non-generic ImageFrameCollection tests
antonfirsov Jun 8, 2019
bb7a51f
cleanup + docs + more tests
antonfirsov Jun 8, 2019
ea34548
implement ImageFrameCollection methods
antonfirsov Jun 8, 2019
5e05056
tests for generic PixelOperations.To<TDest>()
antonfirsov Jun 9, 2019
87958af
experimental implementation
antonfirsov Jun 9, 2019
7df1123
fix .ttinclude
antonfirsov Jun 9, 2019
678beb0
generate generic From<TSourcePixel>(...)
antonfirsov Jun 9, 2019
d33bcf4
fix RgbaVector <--> BT709 Gray pixel conversion
antonfirsov Jun 9, 2019
c64936b
Gray8 and Gray16 using ConvertFromRgbaScaledVector4() by default
antonfirsov Jun 10, 2019
f0c1b1c
fixed all conversion tests
antonfirsov Jun 10, 2019
c8517f4
ConstructGif_FromDifferentPixelTypes
antonfirsov Jun 16, 2019
06ea84f
fix xmldoc and other StyelCop findings
antonfirsov Jun 16, 2019
e108573
Merge branch 'master' into af/nongeneric-framecollection
antonfirsov Jun 23, 2019
f3c31f5
re-enable all target frameworks
antonfirsov Jun 23, 2019
451c609
fix NonGenericAddFrame() and NonGenericInsertFrame()
antonfirsov Jun 24, 2019
9ddee74
fix remaining bugs
antonfirsov Jun 24, 2019
9f78352
Merge branch 'master' into af/nongeneric-framecollection
JimBobSquarePants Jul 1, 2019
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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*.svg text eol=lf
*.targets text eol=lf
*.tt text eol=lf
*.ttinclude text eol=lf
*.ttinclude text eol=crlf
Copy link
Member Author

Choose a reason for hiding this comment

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

for some reason ttinclude files stop working with lf file endings.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, did some reading. No workaround I can find.

*.txt text eol=lf
*.vb text eol=lf
*.yml text eol=lf
Expand Down
13 changes: 12 additions & 1 deletion src/ImageSharp/Common/Helpers/ImageMaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public static byte Get8BitBT709Luminance(byte r, byte g, byte b) =>
public static ushort Get16BitBT709Luminance(ushort r, ushort g, ushort b) =>
(ushort)((r * .2126F) + (g * .7152F) + (b * .0722F));

/// <summary>
/// Gets the luminance from the rgb components using the formula as specified by ITU-R Recommendation BT.709.
/// </summary>
/// <param name="r">The red component.</param>
/// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param>
/// <returns>The <see cref="ushort"/>.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public static ushort Get16BitBT709Luminance(float r, float g, float b) =>
(ushort)((r * .2126F) + (g * .7152F) + (b * .0722F));

/// <summary>
/// Scales a value from a 16 bit <see cref="ushort"/> to it's 8 bit <see cref="byte"/> equivalent.
/// </summary>
Expand Down Expand Up @@ -379,4 +390,4 @@ int GetMaxX(ImageFrame<TPixel> pixels)
return GetBoundingRectangle(topLeft, bottomRight);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// (4) Packing <see cref="Image{TPixel}"/> pixels from the <see cref="Vector4"/> buffer. <br/>
/// These operations are executed in <see cref="NumberOfPostProcessorSteps"/> steps.
/// <see cref="PixelRowsPerStep"/> image rows are converted in one step,
/// which means that size of the allocated memory is limited (does not depend on <see cref="ImageFrame{TPixel}.Height"/>).
/// which means that size of the allocated memory is limited (does not depend on <see cref="ImageFrame.Height"/>).
/// </summary>
internal class JpegImagePostProcessor : IDisposable
{
Expand Down Expand Up @@ -177,4 +177,4 @@ private void ConvertColorsInto<TPixel>(ImageFrame<TPixel> destination)
}
}
}
}
}
12 changes: 11 additions & 1 deletion src/ImageSharp/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ internal Image(
/// </summary>
protected Configuration Configuration { get; }

/// <summary>
/// Gets the <see cref="ImageFrameCollection"/> implementing the public <see cref="Frames"/> property.
/// </summary>
protected abstract ImageFrameCollection NonGenericFrameCollection { get; }

/// <inheritdoc/>
public PixelTypeInfo PixelType { get; }

Expand All @@ -65,6 +70,11 @@ internal Image(
/// <inheritdoc/>
public ImageMetadata Metadata { get; }

/// <summary>
/// Gets the frames of the image as (non-generic) <see cref="ImageFrameCollection"/>.
/// </summary>
public ImageFrameCollection Frames => this.NonGenericFrameCollection;

/// <summary>
/// Gets the pixel buffer.
/// </summary>
Expand Down Expand Up @@ -137,4 +147,4 @@ public void Visit<TPixel>(Image<TPixel> image)
}
}
}
}
}
10 changes: 5 additions & 5 deletions src/ImageSharp/ImageFrame.LoadPixelData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace SixLabors.ImageSharp
{
/// <content>
/// Adds static methods allowing the creation of new image from raw pixel data.
/// Contains methods for loading raw pixel data.
/// </content>
internal static class ImageFrame
public partial class ImageFrame
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given byte array in <typeparamref name="TPixel"/> format.
Expand All @@ -22,7 +22,7 @@ internal static class ImageFrame
/// <param name="height">The height of the final image.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<byte> data, int width, int height)
internal static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<byte> data, int width, int height)
where TPixel : struct, IPixel<TPixel>
=> LoadPixelData(configuration, MemoryMarshal.Cast<byte, TPixel>(data), width, height);

Expand All @@ -35,7 +35,7 @@ public static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configurati
/// <param name="height">The height of the final image.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<TPixel> data, int width, int height)
internal static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<TPixel> data, int width, int height)
where TPixel : struct, IPixel<TPixel>
{
int count = width * height;
Expand All @@ -48,4 +48,4 @@ public static ImageFrame<TPixel> LoadPixelData<TPixel>(Configuration configurati
return image;
}
}
}
}
91 changes: 91 additions & 0 deletions src/ImageSharp/ImageFrame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;

using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Memory;
using SixLabors.Primitives;

namespace SixLabors.ImageSharp
{
/// <summary>
/// Represents a pixel-agnostic image frame containing all pixel data and <see cref="ImageFrameMetadata"/>.
/// In case of animated formats like gif, it contains the single frame in a animation.
/// In all other cases it is the only frame of the image.
/// </summary>
public abstract partial class ImageFrame : IDisposable
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageFrame"/> class.
/// </summary>
/// <param name="configuration">The <see cref="Configuration"/>.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="metadata">The <see cref="ImageFrameMetadata"/>.</param>
protected ImageFrame(Configuration configuration, int width, int height, ImageFrameMetadata metadata)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.NotNull(metadata, nameof(metadata));

this.Configuration = configuration;
this.MemoryAllocator = configuration.MemoryAllocator;
this.Width = width;
this.Height = height;
this.Metadata = metadata;
}

/// <summary>
/// Gets the <see cref="MemoryAllocator" /> to use for buffer allocations.
/// </summary>
public MemoryAllocator MemoryAllocator { get; }

/// <summary>
/// Gets the <see cref="Configuration"/> instance associated with this <see cref="ImageFrame{TPixel}"/>.
/// </summary>
internal Configuration Configuration { get; }

/// <summary>
/// Gets the width.
/// </summary>
public int Width { get; private set; }

/// <summary>
/// Gets the height.
/// </summary>
public int Height { get; private set; }

/// <summary>
/// Gets the metadata of the frame.
/// </summary>
public ImageFrameMetadata Metadata { get; }

/// <summary>
/// Gets the size of the frame.
/// </summary>
/// <returns>The <see cref="Size"/></returns>
public Size Size() => new Size(this.Width, this.Height);

/// <summary>
/// Gets the bounds of the frame.
/// </summary>
/// <returns>The <see cref="Rectangle"/></returns>
public Rectangle Bounds() => new Rectangle(0, 0, this.Width, this.Height);

/// <inheritdoc />
public abstract void Dispose();

internal abstract void CopyPixelsTo<TDestinationPixel>(Span<TDestinationPixel> destination)
where TDestinationPixel : struct, IPixel<TDestinationPixel>;

/// <summary>
/// Updates the size of the image frame.
/// </summary>
internal void UpdateSize(Size size)
{
this.Width = size.Width;
this.Height = size.Height;
}
}
}
Loading