Reorganise Filters folder

This commit is contained in:
BobLd
2024-10-15 22:00:45 +01:00
parent e903b6c365
commit c6793da4f4
7 changed files with 805 additions and 802 deletions

View File

@@ -1,6 +1,6 @@
namespace UglyToad.PdfPig.Tests.Filters
{
using PdfPig.Filters;
using PdfPig.Filters.Lzw;
public class BitStreamTests
{

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.Filters
namespace UglyToad.PdfPig.Filters.CcittFax
{
/// <summary>
/// Specifies the compression type to use with <see cref="T:UglyToad.PdfPig.Filters.CcittFaxDecoderStream" />.

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.Filters
namespace UglyToad.PdfPig.Filters.CcittFax
{
using System;
using System.IO;
@@ -6,8 +6,9 @@
/// <summary>
/// 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
/// </para>
/// </summary>
internal sealed class CcittFaxDecoderStream : StreamWrapper
{
@@ -294,9 +295,9 @@
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++;
}
@@ -305,7 +306,7 @@
byteIndex = index / 8;
var value = (byte)(white ? 0x00 : 0xff);
while ((nextChange - index) > 7)
while (nextChange - index > 7)
{
decodedRow[byteIndex] = value;
index += 8;
@@ -313,14 +314,14 @@
}
}
while ((nextChange - index) > 0)
while (nextChange - index > 0)
{
if (index % 8 == 0)
{
decodedRow[byteIndex] = 0;
}
decodedRow[byteIndex] |= (byte)(white ? 0 : 1 << (7 - ((index) % 8)));
decodedRow[byteIndex] |= (byte)(white ? 0 : 1 << 7 - index % 8);
index++;
}
@@ -389,7 +390,7 @@
bufferPos = 0;
}
var isSet = ((buffer >> (7 - bufferPos)) & 1) == 1;
var isSet = (buffer >> 7 - bufferPos & 1) == 1;
bufferPos++;
@@ -447,7 +448,7 @@
return read;
}
private class Node
private sealed class Node
{
public Node? Left { get; set; }
public Node? Right { get; set; }
@@ -480,7 +481,7 @@
}
}
private class Tree
private sealed class Tree
{
public Node Root { get; } = new Node();
@@ -491,7 +492,7 @@
for (var i = 0; i < depth; i++)
{
var bitPos = depth - 1 - i;
var isSet = ((path >> bitPos) & 1) == 1;
var isSet = (path >> bitPos & 1) == 1;
var next = current.Walk(isSet);
if (next is null)
@@ -527,7 +528,7 @@
for (var i = 0; i < depth; i++)
{
var bitPos = depth - 1 - i;
var isSet = ((path >> bitPos) & 1) == 1;
var isSet = (path >> bitPos & 1) == 1;
var next = current.Walk(isSet);
if (next is null)

View File

@@ -3,6 +3,7 @@
using System;
using System.IO;
using Tokens;
using CcittFax;
using Util;
/// <summary>

View File

@@ -1,4 +1,4 @@
namespace UglyToad.PdfPig.Filters
namespace UglyToad.PdfPig.Filters.Lzw
{
using System;
@@ -53,7 +53,7 @@
}
// 'And' out the leading bits.
var firstBitOfDataWithinInt = (sizeof(int) * 8) - numberOfBits;
var firstBitOfDataWithinInt = sizeof(int) * 8 - numberOfBits;
result &= (int)(0xffffffff >> firstBitOfDataWithinInt);
currentWithinByteBitOffset = endWithinByteBitOffset;

View File

@@ -4,6 +4,7 @@ namespace UglyToad.PdfPig.Filters
{
using System;
using System.Collections.Generic;
using Lzw;
using Tokens;
using Util;