mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 10:02:32 +02:00
c94b5fb7f1
- **Windows MSI:** - (Fix) Use the folder programs x64 instead of x86 for new installation path (#254) - (Improvement) Mark program and all files as x64 - (Improvement) Add UVtools logo to side panel and top banner - (Improvement) Add open-source logo to side panel - (Improvement) License text aligment and bold title - (Add) File format: OSLA / ODLP / OMSLA - Universal binary file format - (Add) Calibration - Lift height: Generates test models with various strategies and increments to measure the optimal lift height or peel forces for layers given the printed area - (Add) Layer Actions - Export layers to images (PNG, JPG/JPEG, JP2, TIF/TIFF, BMP, PBM, PGM, SR/RAS and SVG) - (Add) About box: License with link - (Add) Include a copy of the LICENSE on the packages - (Improvement) File formats: Implement `Wait time before cure` properties on file formats with light-off delay, when used it will calculate the right light-off delay with that extra time and set to `LightOffDelay` property - (Improvement) Change all date times to Utc instead of local - (Fix) Tool - Flip: 'Both' were not working correctly - (Fix) Linux: File 'UVtools.sh' with incorrect line break type, changed to \n (#258)
93 lines
3.2 KiB
C#
93 lines
3.2 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using System.IO;
|
|
|
|
namespace UVtools.Core.Extensions
|
|
{
|
|
public static class FileStreamExtensions
|
|
{
|
|
public static uint ReadBytes(this FileStream fs, byte[] bytes, int offset = 0)
|
|
{
|
|
return (uint)fs.Read(bytes, offset, bytes.Length);
|
|
}
|
|
|
|
public static byte[] ReadBytes(this FileStream fs, int length, int offset = 0)
|
|
{
|
|
var buffer = new byte[length];
|
|
fs.Read(buffer, offset, length);
|
|
return buffer;
|
|
}
|
|
|
|
public static byte[] ReadBytes(this FileStream fs, uint length, int offset = 0)
|
|
=> fs.ReadBytes((int)length, offset);
|
|
|
|
public static uint ReadUShortLittleEndian(this FileStream fs, int offset = 0)
|
|
{
|
|
return BitExtensions.ToUShortLittleEndian(fs.ReadBytes(2, offset));
|
|
}
|
|
|
|
public static uint ReadUShortBigEndian(this FileStream fs, int offset = 0)
|
|
{
|
|
return BitExtensions.ToUShortBigEndian(fs.ReadBytes(2, offset));
|
|
}
|
|
|
|
public static uint ReadUIntLittleEndian(this FileStream fs, int offset = 0)
|
|
{
|
|
return BitExtensions.ToUIntLittleEndian(fs.ReadBytes(4, offset));
|
|
}
|
|
|
|
public static uint ReadUIntBigEndian(this FileStream fs, int offset = 0)
|
|
{
|
|
return BitExtensions.ToUIntBigEndian(fs.ReadBytes(4, offset));
|
|
}
|
|
|
|
public static void WriteUShortLittleEndian(this FileStream fs, ushort value, int offset = 0)
|
|
{
|
|
fs.WriteBytes(BitExtensions.ToBytesLittleEndian(value), offset);
|
|
}
|
|
|
|
public static void WriteUShortBigEndian(this FileStream fs, ushort value, int offset = 0)
|
|
{
|
|
fs.WriteBytes(BitExtensions.ToBytesBigEndian(value), offset);
|
|
}
|
|
|
|
public static void WriteUIntLittleEndian(this FileStream fs, uint value, int offset = 0)
|
|
{
|
|
fs.WriteBytes(BitExtensions.ToBytesLittleEndian(value), offset);
|
|
}
|
|
|
|
public static void WriteUIntBigEndian(this FileStream fs, uint value, int offset = 0)
|
|
{
|
|
fs.WriteBytes(BitExtensions.ToBytesBigEndian(value), offset);
|
|
}
|
|
|
|
public static uint WriteStream(this FileStream fs, MemoryStream stream, int offset = 0)
|
|
{
|
|
return fs.WriteBytes(stream.ToArray(), offset);
|
|
}
|
|
|
|
public static uint WriteBytes(this FileStream fs, byte[] bytes, int offset = 0)
|
|
{
|
|
fs.Write(bytes, offset, bytes.Length);
|
|
return (uint)bytes.Length;
|
|
}
|
|
|
|
public static uint WriteBytes(this Stream stream, byte[] bytes, int offset = 0)
|
|
{
|
|
stream.Write(bytes, offset, bytes.Length);
|
|
return (uint)bytes.Length;
|
|
}
|
|
|
|
public static uint WriteSerialize(this FileStream fs, object data, int offset = 0)
|
|
{
|
|
return Helpers.SerializeWriteFileStream(fs, data, offset);
|
|
}
|
|
}
|
|
}
|