Added a viewer for the IQ chart files.
This commit is contained in:
parent
d83bdb986d
commit
e020969df0
2
.gitignore
vendored
2
.gitignore
vendored
@ -114,3 +114,5 @@ imgui.ini
|
||||
/PrivateDataSpecifiers/skyscraper8.EPGCollectorPort/obj/Debug/net8.0
|
||||
/PrivateDataSpecifiers/skyscraper8.EPGCollectorPort/obj
|
||||
/.vs/skyscraper8/CopilotIndices/17.14.827.52834
|
||||
/GUIs/skyscraper8.AnagramViewer/obj
|
||||
/GUIs/skyscraper8.AnagramViewer/bin/Debug/net8.0-windows
|
||||
|
||||
68
GUIs/skyscraper8.AnagramViewer/Handlers/IQHandler.cs
Normal file
68
GUIs/skyscraper8.AnagramViewer/Handlers/IQHandler.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using skyscraper5.Skyscraper.IO;
|
||||
using skyscraper8.Skyscraper.Drawing;
|
||||
|
||||
namespace skyscraper8.AnagramViewer.Handlers
|
||||
{
|
||||
internal class IQHandler : IFileTypeHandler
|
||||
{
|
||||
public DataType CheckDataType(Stream input)
|
||||
{
|
||||
byte readUInt8 = input.ReadUInt8();
|
||||
if (readUInt8 == 0x41)
|
||||
return DataType.Image;
|
||||
return DataType.Unknown;
|
||||
}
|
||||
|
||||
public Image AsImage(Stream input)
|
||||
{
|
||||
IqChartData iqChartData = IqChartData.LoadFrom(input);
|
||||
|
||||
Bitmap bitmap = new Bitmap(256, 256,PixelFormat.Format24bppRgb);
|
||||
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
|
||||
|
||||
byte[] buffer = new byte[(256 * 256) * 3];
|
||||
int oPos = 0;
|
||||
for (int y = 0; y < 256; y++)
|
||||
{
|
||||
for (int x = 0; x < 256; x++)
|
||||
{
|
||||
byte b = iqChartData.IQ[y][x];
|
||||
if (b != 0)
|
||||
{
|
||||
buffer[oPos] = b; //R
|
||||
buffer[oPos + 1] = 0; //G
|
||||
buffer[oPos + 2] = (byte)(255 - b); //B
|
||||
|
||||
buffer[oPos] = (byte)(~buffer[oPos]);
|
||||
buffer[oPos + 1] = 0;
|
||||
buffer[oPos + 2] = (byte)(~buffer[oPos + 2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[oPos] = 255;
|
||||
buffer[oPos + 1] = 255;
|
||||
buffer[oPos + 2] = 255;
|
||||
}
|
||||
|
||||
oPos += 3;
|
||||
}
|
||||
}
|
||||
|
||||
Marshal.Copy(buffer, 0, bitmapData.Scan0, buffer.Length);
|
||||
bitmap.UnlockBits(bitmapData);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public string AsText(Stream input)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
GUIs/skyscraper8.AnagramViewer/IFileTypeHandler.cs
Normal file
23
GUIs/skyscraper8.AnagramViewer/IFileTypeHandler.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace skyscraper8.AnagramViewer
|
||||
{
|
||||
internal interface IFileTypeHandler
|
||||
{
|
||||
DataType CheckDataType(Stream input);
|
||||
Image AsImage(Stream input);
|
||||
string AsText(Stream input);
|
||||
|
||||
}
|
||||
|
||||
internal enum DataType
|
||||
{
|
||||
Unknown,
|
||||
Image,
|
||||
Text
|
||||
}
|
||||
}
|
||||
62
GUIs/skyscraper8.AnagramViewer/ImageViewer.Designer.cs
generated
Normal file
62
GUIs/skyscraper8.AnagramViewer/ImageViewer.Designer.cs
generated
Normal file
@ -0,0 +1,62 @@
|
||||
namespace skyscraper8.AnagramViewer
|
||||
{
|
||||
partial class ImageViewer
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
pictureBox1 = new PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.BorderStyle = BorderStyle.Fixed3D;
|
||||
pictureBox1.Dock = DockStyle.Fill;
|
||||
pictureBox1.Location = new Point(0, 0);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(800, 450);
|
||||
pictureBox1.TabIndex = 0;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// ImageViewer
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(pictureBox1);
|
||||
FormBorderStyle = FormBorderStyle.FixedToolWindow;
|
||||
Name = "ImageViewer";
|
||||
Text = "ImageViewer";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal PictureBox pictureBox1;
|
||||
}
|
||||
}
|
||||
23
GUIs/skyscraper8.AnagramViewer/ImageViewer.cs
Normal file
23
GUIs/skyscraper8.AnagramViewer/ImageViewer.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace skyscraper8.AnagramViewer
|
||||
{
|
||||
public partial class ImageViewer : Form
|
||||
{
|
||||
public ImageViewer(Image asImage)
|
||||
{
|
||||
InitializeComponent();
|
||||
pictureBox1.Image = asImage;
|
||||
this.Width = asImage.Width;
|
||||
this.Height = asImage.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
GUIs/skyscraper8.AnagramViewer/ImageViewer.resx
Normal file
120
GUIs/skyscraper8.AnagramViewer/ImageViewer.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
77
GUIs/skyscraper8.AnagramViewer/Program.cs
Normal file
77
GUIs/skyscraper8.AnagramViewer/Program.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace skyscraper8.AnagramViewer
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
MessageBox.Show("Invalid function call!");
|
||||
return;
|
||||
}
|
||||
|
||||
FileInfo fi = new FileInfo(args[0]);
|
||||
if (!fi.Exists)
|
||||
{
|
||||
MessageBox.Show("Couldn't find {0}!", args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
FileStream fileStream = fi.OpenRead();
|
||||
BufferedStream bufferedStream = new BufferedStream(fileStream, 2048);
|
||||
|
||||
IFileTypeHandler usableHandler = null;
|
||||
DataType determiendDataType = DataType.Unknown;
|
||||
Type fileHandlerType = typeof(IFileTypeHandler);
|
||||
Assembly assembly = fileHandlerType.Assembly;
|
||||
Type[] types = assembly.GetTypes();
|
||||
foreach (Type typeCandidate in types)
|
||||
{
|
||||
if (!typeCandidate.IsAssignableTo(fileHandlerType))
|
||||
continue;
|
||||
|
||||
if (typeCandidate.IsInterface)
|
||||
continue;
|
||||
|
||||
bufferedStream.Position = 0;
|
||||
IFileTypeHandler instance = (IFileTypeHandler)Activator.CreateInstance(typeCandidate);
|
||||
DataType checkDataType = instance.CheckDataType(bufferedStream);
|
||||
if (checkDataType != DataType.Unknown)
|
||||
{
|
||||
usableHandler = instance;
|
||||
determiendDataType = checkDataType;
|
||||
bufferedStream.Position = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (usableHandler == null)
|
||||
{
|
||||
MessageBox.Show(String.Format("Don't know what type of file {0} is.", fi.FullName));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (determiendDataType)
|
||||
{
|
||||
case DataType.Image:
|
||||
Image asImage = usableHandler.AsImage(bufferedStream);
|
||||
ImageViewer imageViewer = new ImageViewer(asImage);
|
||||
Application.Run(imageViewer);
|
||||
return;
|
||||
default:
|
||||
MessageBox.Show(String.Format("Don't know how to handle files of type {0}", determiendDataType.ToString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"profiles": {
|
||||
"skyscraper8.AnagramViewer": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "\"C:\\Users\\Sascha Schiemann\\source\\repos\\skyscraper8\\skyscraper8\\bin\\Debug\\net8.0\\iq.bin\""
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\skyscraper8\skyscraper8.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Update="ImageViewer.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -61,6 +61,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper8.UI.ImGui", "GUI
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper8.EPGCollectorPort", "PrivateDataSpecifiers\skyscraper8.EPGCollectorPort\skyscraper8.EPGCollectorPort.csproj", "{CF21D250-9804-4191-89F5-95821E3AF39D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper8.AnagramViewer", "GUIs\skyscraper8.AnagramViewer\skyscraper8.AnagramViewer.csproj", "{EBB6B1CF-2597-4962-AA31-2B42B4C28C7D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -151,6 +153,10 @@ Global
|
||||
{CF21D250-9804-4191-89F5-95821E3AF39D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CF21D250-9804-4191-89F5-95821E3AF39D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CF21D250-9804-4191-89F5-95821E3AF39D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EBB6B1CF-2597-4962-AA31-2B42B4C28C7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EBB6B1CF-2597-4962-AA31-2B42B4C28C7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EBB6B1CF-2597-4962-AA31-2B42B4C28C7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EBB6B1CF-2597-4962-AA31-2B42B4C28C7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -175,6 +181,7 @@ Global
|
||||
{46CACA1C-F9B2-2FE0-2068-716F381325E9} = {E23457C5-3A34-48EE-8107-C91E2C174B2D}
|
||||
{BDBDB7A9-D0A4-9B89-0801-2935B2066551} = {E23457C5-3A34-48EE-8107-C91E2C174B2D}
|
||||
{CF21D250-9804-4191-89F5-95821E3AF39D} = {56729C39-B90E-4DF3-A557-DB93436FB5FF}
|
||||
{EBB6B1CF-2597-4962-AA31-2B42B4C28C7D} = {E23457C5-3A34-48EE-8107-C91E2C174B2D}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5147EFA3-3D4E-4FDE-8A36-5840E8F1B80E}
|
||||
|
||||
@ -8,7 +8,7 @@ using skyscraper5.Skyscraper.IO;
|
||||
|
||||
namespace skyscraper8.Skyscraper.Drawing
|
||||
{
|
||||
internal class IqChartData
|
||||
public class IqChartData
|
||||
{
|
||||
private IqChartData()
|
||||
{
|
||||
@ -31,6 +31,25 @@ namespace skyscraper8.Skyscraper.Drawing
|
||||
return child;
|
||||
}
|
||||
|
||||
public static IqChartData LoadFrom(Stream indata)
|
||||
{
|
||||
if (indata.ReadUInt8() != 0x41)
|
||||
throw new ArgumentException("That stream isn't IQ Data!", nameof(indata));
|
||||
|
||||
IqChartData result = null;
|
||||
while (indata.GetAvailableBytes() >= 4)
|
||||
{
|
||||
if (result == null)
|
||||
result = new IqChartData();
|
||||
|
||||
int packSize = indata.ReadInt32LE();
|
||||
sbyte[] sbytes = indata.ReadSBytes(packSize);
|
||||
result.PushPacket(sbytes);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool IsComplete { get; private set; }
|
||||
|
||||
|
||||
@ -38,8 +57,8 @@ namespace skyscraper8.Skyscraper.Drawing
|
||||
{
|
||||
for (long l = 0; l < buffer.Length; l += 2)
|
||||
{
|
||||
byte i = (byte)buffer[l];
|
||||
byte q = (byte)buffer[l + 1];
|
||||
byte i = (byte)(buffer[l] + sbyte.MaxValue);
|
||||
byte q = (byte)(buffer[l + 1] + sbyte.MaxValue);
|
||||
|
||||
if (IQ[i][q] != 255)
|
||||
{
|
||||
|
||||
@ -123,6 +123,27 @@ namespace skyscraper5.Skyscraper.IO
|
||||
return buffer;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static sbyte[] ReadSBytes(this Stream stream, long length)
|
||||
{
|
||||
if (length > Int32.MaxValue)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
if (length == 0)
|
||||
return new sbyte[0];
|
||||
if (length < 0)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
||||
int length32 = (int)length;
|
||||
|
||||
sbyte[] buffer = new sbyte[length32];
|
||||
for (int i = 0; i < length32; i++)
|
||||
{
|
||||
buffer[i] = (sbyte)stream.ReadUInt8();
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static byte ReadUInt8(this Stream stream)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user