Skip to content

Commit

Permalink
!提高导出图片功能对轻微格式错误的图片的兼容性
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed Jul 22, 2022
1 parent b821742 commit ab9a561
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 9 additions & 6 deletions App/Processor/Imaging/ImageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private static byte[] DecodeImage(ImageInfo info, ImageExtracterOptions options)
return decodedBytes;
}

private static void InvertBits(byte[] outBuf) {
static void InvertBits(byte[] outBuf) {
int len = outBuf.Length;
for (int t = 0; t < len; ++t) {
outBuf[t] ^= 0xff;
Expand All @@ -235,7 +235,7 @@ internal void CreatePaletteAndIccProfile(FreeImageBitmap bmp) {
}
}

private void CreatePalette(FreeImageBitmap bmp) {
void CreatePalette(FreeImageBitmap bmp) {
//if (PaletteColorSpace == null) {
// //todo++ 缺少色域信息的图片不一定是灰度图像
// if (bmp.HasPalette) {
Expand Down Expand Up @@ -286,15 +286,15 @@ private void CreatePalette(FreeImageBitmap bmp) {
PaletteArray = pal.AsArray;
}

private static bool IsDecodeParamInverted(PdfDictionary data, bool blackIs1) {
static bool IsDecodeParamInverted(PdfDictionary data, bool blackIs1) {
var a = data.GetAsArray(PdfName.DECODE);
if (a?.Size == 2 && a[0].Type == PdfObject.NUMBER) {
blackIs1 = ((PdfNumber)a[0]).IntValue == (blackIs1 ? 0 : 1);
}
return blackIs1;
}

private static byte[] DecodeStreamContent(PdfImageData data, IList<PdfObject> filters) {
static byte[] DecodeStreamContent(PdfImageData data, IList<PdfObject> filters) {
var buffer = data.RawBytes;
if (filters.Count == 0) {
return buffer;
Expand Down Expand Up @@ -351,7 +351,7 @@ private static byte[] DecodeStreamContent(PdfImageData data, IList<PdfObject> fi
return buffer;
}

private static PixelFormat GetPixelFormat(int byteLength, ImageInfo info) {
static PixelFormat GetPixelFormat(int byteLength, ImageInfo info) {
var pf = PixelFormat.Undefined;
var components = byteLength / info.Width / info.Height;
switch (info.BitsPerComponent) {
Expand All @@ -363,6 +363,9 @@ private static PixelFormat GetPixelFormat(int byteLength, ImageInfo info) {
case 4: pf = PixelFormat.Format4bppIndexed; break;
case 8:
switch (components) {
case 0:
Trace.WriteLine("Warning: Not enough bytes.");
goto case 1;
case 1:
pf = PixelFormat.Format8bppIndexed;
break;
Expand Down Expand Up @@ -402,7 +405,7 @@ private static PixelFormat GetPixelFormat(int byteLength, ImageInfo info) {
return pf;
}

private static void ExportColorspace(PdfObject cs, ImageInfo info) {
static void ExportColorspace(PdfObject cs, ImageInfo info) {
if (cs == null) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions 更新历史.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
优化了部分界面显示。
使用相对路径读写合并文件功能的文件列表。
调整识别文本功能默认的识别结果格式,在识别结果文件不是 XML 时给出提示。
提高导出图片功能对轻微格式错误的图片的兼容性。
修复问题:
书签编辑器页码、书签级别等数值或文本编辑框太窄。
合并文件功能在添加的目录存在无访问权限文件或子目录时导致程序崩溃。
Expand Down

0 comments on commit ab9a561

Please sign in to comment.