mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-24 13:23:40 +08:00
switch classes still using the cos object approach to the tokenization approach initally used for parsing cmap files.
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
namespace UglyToad.PdfPig.Tokenization.Tokens
|
||||
{
|
||||
using System;
|
||||
using Filters;
|
||||
|
||||
internal class StreamToken : IDataToken<byte[]>
|
||||
{
|
||||
private readonly object lockObject = new object();
|
||||
|
||||
private byte[] decodedBytes;
|
||||
|
||||
public DictionaryToken StreamDictionary { get; }
|
||||
|
||||
public byte[] Data { get; }
|
||||
@@ -11,5 +18,28 @@
|
||||
StreamDictionary = streamDictionary;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public byte[] Decode(IFilterProvider filterProvider)
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
if (decodedBytes != null)
|
||||
{
|
||||
return decodedBytes;
|
||||
}
|
||||
|
||||
var filters = filterProvider.GetFilters(StreamDictionary);
|
||||
|
||||
var transform = Data;
|
||||
for (var i = 0; i < filters.Count; i++)
|
||||
{
|
||||
transform = filters[i].Decode(transform, StreamDictionary, i);
|
||||
}
|
||||
|
||||
decodedBytes = transform;
|
||||
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user