load images eagerly for marked content

when a marked content region contains an image we load it eagerly since we won't have access to the necessary classes at evaluation time. we also default image colorspace to the active graphics state colorspace if the dictionary doesn't contain a valid entry.
This commit is contained in:
Eliot Jones
2020-01-10 13:52:21 +00:00
parent 2a579afd4d
commit 17b7cf2f61
7 changed files with 51 additions and 44 deletions

View File

@@ -8,7 +8,6 @@
using Graphics.Operations;
using Tokenization.Scanner;
using XObjects;
using Geometry;
/// <summary>
/// Wraps content parsed from a page content stream for access.
@@ -24,7 +23,6 @@
private readonly IPdfTokenScanner pdfScanner;
private readonly IFilterProvider filterProvider;
private readonly IResourceStore resourceStore;
private readonly bool isLenientParsing;
internal IReadOnlyList<IGraphicsStateOperation> GraphicsStateOperations { get; }
@@ -38,8 +36,7 @@
IReadOnlyList<MarkedContentElement> markedContents,
IPdfTokenScanner pdfScanner,
IFilterProvider filterProvider,
IResourceStore resourceStore,
bool isLenientParsing)
IResourceStore resourceStore)
{
GraphicsStateOperations = graphicsStateOperations;
Letters = letters;
@@ -49,17 +46,14 @@
this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner));
this.filterProvider = filterProvider ?? throw new ArgumentNullException(nameof(filterProvider));
this.resourceStore = resourceStore ?? throw new ArgumentNullException(nameof(resourceStore));
this.isLenientParsing = isLenientParsing;
}
public IEnumerable<IPdfImage> GetImages()
{
foreach (var image in images)
{
IPdfImage result = null;
image.Match(x => { result = XObjectFactory.ReadImage(x, pdfScanner, filterProvider, resourceStore, isLenientParsing); },
x => { result = x; });
var result = image.Match<IPdfImage>(x => XObjectFactory.ReadImage(x, pdfScanner, filterProvider, resourceStore),
x => x);
yield return result;
}