mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-12-22 03:46:07 +08:00
Reorganise Filters folder
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
namespace UglyToad.PdfPig.Tests.Filters
|
namespace UglyToad.PdfPig.Tests.Filters
|
||||||
{
|
{
|
||||||
using PdfPig.Filters;
|
using PdfPig.Filters.Lzw;
|
||||||
|
|
||||||
public class BitStreamTests
|
public class BitStreamTests
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace UglyToad.PdfPig.Filters
|
namespace UglyToad.PdfPig.Filters.CcittFax
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the compression type to use with <see cref="T:UglyToad.PdfPig.Filters.CcittFaxDecoderStream" />.
|
/// Specifies the compression type to use with <see cref="T:UglyToad.PdfPig.Filters.CcittFaxDecoderStream" />.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace UglyToad.PdfPig.Filters
|
namespace UglyToad.PdfPig.Filters.CcittFax
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -6,8 +6,9 @@
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CCITT Modified Huffman RLE, Group 3 (T4) and Group 4 (T6) fax compression.
|
/// CCITT Modified Huffman RLE, Group 3 (T4) and Group 4 (T6) fax compression.
|
||||||
///
|
/// <para>
|
||||||
/// Ported from https://github.com/apache/pdfbox/blob/e644c29279e276bde14ce7a33bdeef0cb1001b3e/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecoderStream.java
|
/// Ported from https://github.com/apache/pdfbox/blob/e644c29279e276bde14ce7a33bdeef0cb1001b3e/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecoderStream.java
|
||||||
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class CcittFaxDecoderStream : StreamWrapper
|
internal sealed class CcittFaxDecoderStream : StreamWrapper
|
||||||
{
|
{
|
||||||
@@ -294,9 +295,9 @@
|
|||||||
|
|
||||||
var byteIndex = index / 8;
|
var byteIndex = index / 8;
|
||||||
|
|
||||||
while (index % 8 != 0 && (nextChange - index) > 0)
|
while (index % 8 != 0 && nextChange - index > 0)
|
||||||
{
|
{
|
||||||
decodedRow[byteIndex] |= (byte)(white ? 0 : 1 << (7 - ((index) % 8)));
|
decodedRow[byteIndex] |= (byte)(white ? 0 : 1 << 7 - index % 8);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +306,7 @@
|
|||||||
byteIndex = index / 8;
|
byteIndex = index / 8;
|
||||||
var value = (byte)(white ? 0x00 : 0xff);
|
var value = (byte)(white ? 0x00 : 0xff);
|
||||||
|
|
||||||
while ((nextChange - index) > 7)
|
while (nextChange - index > 7)
|
||||||
{
|
{
|
||||||
decodedRow[byteIndex] = value;
|
decodedRow[byteIndex] = value;
|
||||||
index += 8;
|
index += 8;
|
||||||
@@ -313,14 +314,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((nextChange - index) > 0)
|
while (nextChange - index > 0)
|
||||||
{
|
{
|
||||||
if (index % 8 == 0)
|
if (index % 8 == 0)
|
||||||
{
|
{
|
||||||
decodedRow[byteIndex] = 0;
|
decodedRow[byteIndex] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
decodedRow[byteIndex] |= (byte)(white ? 0 : 1 << (7 - ((index) % 8)));
|
decodedRow[byteIndex] |= (byte)(white ? 0 : 1 << 7 - index % 8);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +390,7 @@
|
|||||||
bufferPos = 0;
|
bufferPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isSet = ((buffer >> (7 - bufferPos)) & 1) == 1;
|
var isSet = (buffer >> 7 - bufferPos & 1) == 1;
|
||||||
|
|
||||||
bufferPos++;
|
bufferPos++;
|
||||||
|
|
||||||
@@ -447,7 +448,7 @@
|
|||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Node
|
private sealed class Node
|
||||||
{
|
{
|
||||||
public Node? Left { get; set; }
|
public Node? Left { get; set; }
|
||||||
public Node? Right { get; set; }
|
public Node? Right { get; set; }
|
||||||
@@ -480,7 +481,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Tree
|
private sealed class Tree
|
||||||
{
|
{
|
||||||
public Node Root { get; } = new Node();
|
public Node Root { get; } = new Node();
|
||||||
|
|
||||||
@@ -491,7 +492,7 @@
|
|||||||
for (var i = 0; i < depth; i++)
|
for (var i = 0; i < depth; i++)
|
||||||
{
|
{
|
||||||
var bitPos = depth - 1 - i;
|
var bitPos = depth - 1 - i;
|
||||||
var isSet = ((path >> bitPos) & 1) == 1;
|
var isSet = (path >> bitPos & 1) == 1;
|
||||||
var next = current.Walk(isSet);
|
var next = current.Walk(isSet);
|
||||||
|
|
||||||
if (next is null)
|
if (next is null)
|
||||||
@@ -527,7 +528,7 @@
|
|||||||
for (var i = 0; i < depth; i++)
|
for (var i = 0; i < depth; i++)
|
||||||
{
|
{
|
||||||
var bitPos = depth - 1 - i;
|
var bitPos = depth - 1 - i;
|
||||||
var isSet = ((path >> bitPos) & 1) == 1;
|
var isSet = (path >> bitPos & 1) == 1;
|
||||||
var next = current.Walk(isSet);
|
var next = current.Walk(isSet);
|
||||||
|
|
||||||
if (next is null)
|
if (next is null)
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Tokens;
|
using Tokens;
|
||||||
|
using CcittFax;
|
||||||
using Util;
|
using Util;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace UglyToad.PdfPig.Filters
|
namespace UglyToad.PdfPig.Filters.Lzw
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 'And' out the leading bits.
|
// 'And' out the leading bits.
|
||||||
var firstBitOfDataWithinInt = (sizeof(int) * 8) - numberOfBits;
|
var firstBitOfDataWithinInt = sizeof(int) * 8 - numberOfBits;
|
||||||
result &= (int)(0xffffffff >> firstBitOfDataWithinInt);
|
result &= (int)(0xffffffff >> firstBitOfDataWithinInt);
|
||||||
|
|
||||||
currentWithinByteBitOffset = endWithinByteBitOffset;
|
currentWithinByteBitOffset = endWithinByteBitOffset;
|
||||||
@@ -4,6 +4,7 @@ namespace UglyToad.PdfPig.Filters
|
|||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Lzw;
|
||||||
using Tokens;
|
using Tokens;
|
||||||
using Util;
|
using Util;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user