#55 move support for images to page and add inline images

support both xobject and inline images. adds unsupported filters so that exceptions are only thrown when accessing lazily evaluated image.bytes property rather than when opening the page.

treat all warnings as errors.
This commit is contained in:
Eliot Jones
2019-10-08 14:04:36 +01:00
parent e02e130947
commit 68bcaf3901
41 changed files with 1083 additions and 169 deletions

View File

@@ -28,6 +28,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.BeginInlineImage();
}
/// <inheritdoc />

View File

@@ -1,6 +1,9 @@
namespace UglyToad.PdfPig.Graphics.Operations.InlineImages
{
using System;
using System.Collections.Generic;
using System.IO;
using Tokens;
/// <inheritdoc />
/// <summary>
@@ -12,22 +15,27 @@
/// The symbol for this operation in a stream.
/// </summary>
public const string Symbol = "ID";
/// <summary>
/// The instance of the <see cref="BeginInlineImageData"/> operation.
/// </summary>
public static readonly BeginInlineImageData Value = new BeginInlineImageData();
/// <inheritdoc />
public string Operator => Symbol;
private BeginInlineImageData()
/// <summary>
/// The key-value pairs which specify attributes of the following image.
/// </summary>
public IReadOnlyDictionary<NameToken, IToken> Dictionary { get; }
/// <summary>
/// Create a new <see cref="BeginInlineImageData"/>.
/// </summary>
public BeginInlineImageData(IReadOnlyDictionary<NameToken, IToken> dictionary)
{
Dictionary = dictionary ?? throw new ArgumentNullException(nameof(dictionary));
}
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.SetInlineImageProperties(Dictionary);
}
/// <inheritdoc />

View File

@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using Tokens;
/// <inheritdoc />
/// <summary>
@@ -15,14 +14,9 @@
/// The symbol for this operation in a stream.
/// </summary>
public const string Symbol = "EI";
/// <summary>
/// The tokens declared in order for this inline image object.
/// </summary>
public IReadOnlyList<IToken> ImageTokens { get; }
/// <summary>
/// The raw data for the inline image which should be interpreted according to the <see cref="ImageTokens"/>.
/// The raw data for the inline image which should be interpreted according to the corresponding <see cref="BeginInlineImageData.Dictionary"/>.
/// </summary>
public IReadOnlyList<byte> ImageData { get; }
@@ -32,17 +26,16 @@
/// <summary>
/// Create a new <see cref="EndInlineImage"/> operation.
/// </summary>
/// <param name="imageTokens">The tokens which were set during the declaration of this image.</param>
/// <param name="imageData">The raw byte data of this image.</param>
public EndInlineImage(IReadOnlyList<IToken> imageTokens, IReadOnlyList<byte> imageData)
public EndInlineImage(IReadOnlyList<byte> imageData)
{
ImageTokens = imageTokens ?? throw new ArgumentNullException(nameof(imageTokens));
ImageData = imageData ?? throw new ArgumentNullException(nameof(imageData));
}
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.EndInlineImage(ImageData);
}
/// <inheritdoc />