+ FastLZ: FastLZ压缩解压类
This commit is contained in:
parent
aa409b0d7b
commit
8f34889655
Binary file not shown.
@ -1,4 +1,33 @@
|
|||||||
using System;
|
/******************************************************************************
|
||||||
|
* SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。
|
||||||
|
* CopyRight (C) 2012-2022 ShenYongHua(沈永华).
|
||||||
|
* QQ群:56829229 QQ:17612584 EMail:SunnyUI@QQ.Com
|
||||||
|
*
|
||||||
|
* Blog: https://www.cnblogs.com/yhuse
|
||||||
|
* Gitee: https://gitee.com/yhuse/SunnyUI
|
||||||
|
* GitHub: https://github.com/yhuse/SunnyUI
|
||||||
|
*
|
||||||
|
* SunnyUI.dll can be used for free under the GPL-3.0 license.
|
||||||
|
* If you use this code, please keep this note.
|
||||||
|
* 如果您使用此代码,请保留此说明。
|
||||||
|
******************************************************************************
|
||||||
|
* 文件名称: FastLZ.cs
|
||||||
|
* 文件说明: FastLZ压缩解压类
|
||||||
|
* 当前版本: V3.1
|
||||||
|
* 创建日期: 2022-03-31
|
||||||
|
* 引用地址: https://ariya.github.io/FastLZ/
|
||||||
|
*
|
||||||
|
* FastLZ (MIT license) is an ANSI C/C90 implementation of Lempel-Ziv 77
|
||||||
|
* algorithm (LZ77) of lossless data compression. It is suitable to compress
|
||||||
|
* series of text/paragraphs, sequences of raw pixel data, or any other blocks
|
||||||
|
* of data with lots of repetition. It is not intended to be used on images,
|
||||||
|
* videos, and other formats of data typically already in an optimal
|
||||||
|
* compressed form.
|
||||||
|
*
|
||||||
|
* 2022-03-31: V3.1.2 增加文件说明
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@ -37,7 +66,7 @@ namespace Sunny.UI
|
|||||||
/// 是否64位
|
/// 是否64位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool IsSys64bit()
|
public static bool Is64bitApp()
|
||||||
{
|
{
|
||||||
return IntPtr.Size == 8;
|
return IntPtr.Size == 8;
|
||||||
}
|
}
|
||||||
@ -48,7 +77,7 @@ namespace Sunny.UI
|
|||||||
fixed (void* pSrc1 = &input[begin])
|
fixed (void* pSrc1 = &input[begin])
|
||||||
fixed (void* pSrc2 = output)
|
fixed (void* pSrc2 = output)
|
||||||
{
|
{
|
||||||
int outlen = IsSys64bit() ? FastLZx64.FastLZ_Compress(pSrc1, len, pSrc2) : FastLZx86.FastLZ_Compress(pSrc1, len, pSrc2);
|
int outlen = Is64bitApp() ? FastLZx64.FastLZ_Compress(pSrc1, len, pSrc2) : FastLZx86.FastLZ_Compress(pSrc1, len, pSrc2);
|
||||||
byte[] result = new byte[outlen];
|
byte[] result = new byte[outlen];
|
||||||
Array.Copy(output, 0, result, 0, outlen);
|
Array.Copy(output, 0, result, 0, outlen);
|
||||||
return result;
|
return result;
|
||||||
@ -61,7 +90,7 @@ namespace Sunny.UI
|
|||||||
fixed (void* pSrc1 = &input[begin])
|
fixed (void* pSrc1 = &input[begin])
|
||||||
fixed (void* pSrc2 = output)
|
fixed (void* pSrc2 = output)
|
||||||
{
|
{
|
||||||
int outlen = IsSys64bit() ? FastLZx64.FastLZ_Compress_level(level, pSrc1, len, pSrc2) : FastLZx86.FastLZ_Compress_level(level, pSrc1, len, pSrc2);
|
int outlen = Is64bitApp() ? FastLZx64.FastLZ_Compress_level(level, pSrc1, len, pSrc2) : FastLZx86.FastLZ_Compress_level(level, pSrc1, len, pSrc2);
|
||||||
byte[] result = new byte[outlen];
|
byte[] result = new byte[outlen];
|
||||||
Array.Copy(output, 0, result, 0, outlen);
|
Array.Copy(output, 0, result, 0, outlen);
|
||||||
return result;
|
return result;
|
||||||
@ -74,7 +103,7 @@ namespace Sunny.UI
|
|||||||
fixed (byte* pSrc1 = &input[begin])
|
fixed (byte* pSrc1 = &input[begin])
|
||||||
fixed (byte* pSrc2 = output)
|
fixed (byte* pSrc2 = output)
|
||||||
{
|
{
|
||||||
int outlen = IsSys64bit() ? FastLZx64.FastLZ_Decompress(pSrc1, length, pSrc2, maxout) : FastLZx86.FastLZ_Decompress(pSrc1, length, pSrc2, maxout);
|
int outlen = Is64bitApp() ? FastLZx64.FastLZ_Decompress(pSrc1, length, pSrc2, maxout) : FastLZx86.FastLZ_Decompress(pSrc1, length, pSrc2, maxout);
|
||||||
byte[] result = new byte[outlen];
|
byte[] result = new byte[outlen];
|
||||||
Array.Copy(output, 0, result, 0, outlen);
|
Array.Copy(output, 0, result, 0, outlen);
|
||||||
return result;
|
return result;
|
||||||
|
@ -209,7 +209,7 @@ namespace Sunny.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">文件名</param>
|
/// <param name="filename">文件名</param>
|
||||||
/// <returns>结果</returns>
|
/// <returns>结果</returns>
|
||||||
public static FileInfo FileInfo(this string filename)
|
public static FileInfo FileInfo(string filename)
|
||||||
{
|
{
|
||||||
return File.Exists(filename) ? new FileInfo(filename) : null;
|
return File.Exists(filename) ? new FileInfo(filename) : null;
|
||||||
}
|
}
|
||||||
@ -254,7 +254,8 @@ namespace Sunny.UI
|
|||||||
/// <returns>是否运行</returns>
|
/// <returns>是否运行</returns>
|
||||||
public static bool IsRun(string filename)
|
public static bool IsRun(string filename)
|
||||||
{
|
{
|
||||||
return filename.FileInfo().IsRun();
|
FileInfo info = FileInfo(filename);
|
||||||
|
return info == null ? false : info.IsRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -492,7 +493,8 @@ namespace Sunny.UI
|
|||||||
/// <returns>结果</returns>
|
/// <returns>结果</returns>
|
||||||
public static bool TryDelete(string file)
|
public static bool TryDelete(string file)
|
||||||
{
|
{
|
||||||
return file.FileInfo().TryDelete();
|
FileInfo info = FileInfo(file);
|
||||||
|
return info == null ? false : info.TryDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -210,7 +210,7 @@ namespace Sunny.UI
|
|||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Smooth(this Graphics g, bool smooth = true)
|
public static Graphics Smooth(this Graphics g, bool smooth = true)
|
||||||
{
|
{
|
||||||
if (smooth)
|
if (smooth)
|
||||||
{
|
{
|
||||||
@ -220,6 +220,8 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
g.SetDefaultQuality();
|
g.SetDefaultQuality();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,22 +338,24 @@ namespace Sunny.UI
|
|||||||
/// 设置GDI高质量模式抗锯齿
|
/// 设置GDI高质量模式抗锯齿
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public static void SetHighQuality(this Graphics g)
|
public static Graphics SetHighQuality(this Graphics g)
|
||||||
{
|
{
|
||||||
g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
|
g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
|
||||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
g.CompositingQuality = CompositingQuality.HighQuality;
|
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置GDI默认值
|
/// 设置GDI默认值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public static void SetDefaultQuality(this Graphics g)
|
public static Graphics SetDefaultQuality(this Graphics g)
|
||||||
{
|
{
|
||||||
g.SmoothingMode = SmoothingMode.Default;
|
g.SmoothingMode = SmoothingMode.Default;
|
||||||
g.InterpolationMode = InterpolationMode.Default;
|
g.InterpolationMode = InterpolationMode.Default;
|
||||||
g.CompositingQuality = CompositingQuality.Default;
|
g.CompositingQuality = CompositingQuality.Default;
|
||||||
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToHTML(this Color color)
|
public static string ToHTML(this Color color)
|
||||||
|
@ -133,12 +133,16 @@ namespace Sunny.UI
|
|||||||
/// <param name="ms">The ms.</param>
|
/// <param name="ms">The ms.</param>
|
||||||
public static void Delay(int ms)
|
public static void Delay(int ms)
|
||||||
{
|
{
|
||||||
int start = Environment.TickCount;
|
System.Threading.Thread.Sleep(Math.Max(0, ms));
|
||||||
while (Environment.TickCount - start < ms)
|
}
|
||||||
{
|
|
||||||
System.Threading.Thread.Sleep(1);
|
/// <summary>
|
||||||
Application.DoEvents();
|
/// 是否64位
|
||||||
}
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool Is64bitApp()
|
||||||
|
{
|
||||||
|
return IntPtr.Size == 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -665,7 +665,6 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
topmost = baseForm.TopMost;
|
topmost = baseForm.TopMost;
|
||||||
baseForm.TopMost = true;
|
baseForm.TopMost = true;
|
||||||
Application.DoEvents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Form mask = new Form();
|
Form mask = new Form();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user