This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
+524
View File
@@ -0,0 +1,524 @@
using System;
using System.IO;
using UnityEngine;
namespace Gif.Components
{
// Token: 0x02000003 RID: 3
public class AnimatedGifEncoder
{
// Token: 0x06000007 RID: 7 RVA: 0x000021FA File Offset: 0x000005FA
public void SetPaletteSize(int size)
{
if (size < 2 || size > 256)
{
throw new ArgumentOutOfRangeException("size", "size should be between 2 and 256");
}
this.paletteSize = size;
}
// Token: 0x06000008 RID: 8 RVA: 0x00002226 File Offset: 0x00000626
public void SetMaxSize(int bytes)
{
this.limitFileSize = bytes > 0;
this.maxSize = (long)bytes;
}
// Token: 0x06000009 RID: 9 RVA: 0x0000223B File Offset: 0x0000063B
public void SetDelay(int ms)
{
this.delay = (int)Math.Round((double)((float)ms / 10f));
}
// Token: 0x0600000A RID: 10 RVA: 0x00002253 File Offset: 0x00000653
public void SetDispose(int code)
{
if (code >= 0)
{
this.dispose = code;
}
}
// Token: 0x0600000B RID: 11 RVA: 0x00002266 File Offset: 0x00000666
public void SetRepeat(int iter)
{
if (iter >= 0)
{
this.repeat = iter;
}
}
// Token: 0x0600000C RID: 12 RVA: 0x00002279 File Offset: 0x00000679
public void SetTransparent(Color32 c)
{
this.transparent = c;
}
// Token: 0x0600000D RID: 13 RVA: 0x00002284 File Offset: 0x00000684
public bool AddFrame(Image im)
{
bool flag;
if (im == null || !this.started)
{
flag = false;
}
else
{
try
{
if (!this.sizeSet)
{
this.SetSize(im.width, im.height);
}
this.image = im;
this.GetImagePixels();
this.AnalyzePixels();
if (this.firstFrame)
{
this.WriteLSD();
this.WritePalette();
if (this.repeat >= 0)
{
this.WriteNetscapeExt();
}
}
this.WriteGraphicCtrlExt();
bool flag2 = !this.firstFrame && !this.useStaticColorPalette;
this.WriteImageDesc(flag2);
if (flag2)
{
this.WritePalette();
}
this.WritePixels();
this.firstFrame = false;
}
catch (IOException ex)
{
throw ex;
}
flag = this.WriteTemp();
}
return flag;
}
// Token: 0x0600000E RID: 14 RVA: 0x00002374 File Offset: 0x00000774
private bool WriteTemp()
{
bool flag;
if (!this.limitFileSize || this.tempStream.Length + this.bytesWritten < this.maxSize)
{
this.bytesWritten += this.tempStream.Length;
this.tempStream.WriteTo(this.gifStream);
this.tempStream.Position = 0L;
this.tempStream.SetLength(0L);
flag = true;
}
else
{
flag = false;
}
return flag;
}
// Token: 0x0600000F RID: 15 RVA: 0x00002400 File Offset: 0x00000800
public bool Finish()
{
bool flag;
if (!this.started)
{
flag = false;
}
else
{
bool flag2 = true;
this.started = false;
try
{
this.gifStream.WriteByte(59);
this.gifStream.Flush();
if (this.closeStream)
{
this.gifStream.Close();
}
}
catch (IOException ex)
{
flag2 = false;
}
this.transIndex = 0;
this.bytesWritten = 0L;
this.tempStream = null;
this.image = null;
this.pixels = null;
this.indexedPixels = null;
this.colorTab = null;
this.closeStream = false;
this.firstFrame = true;
this.nq = null;
flag = flag2;
}
return flag;
}
// Token: 0x06000010 RID: 16 RVA: 0x000024CC File Offset: 0x000008CC
public void SetFrameRate(float fps)
{
if (fps != 0f)
{
this.delay = (int)Math.Round((double)(100f / fps));
}
}
// Token: 0x06000011 RID: 17 RVA: 0x000024F0 File Offset: 0x000008F0
public void SetStaticColorPaletteMode(bool useStatic)
{
this.useStaticColorPalette = useStatic;
}
// Token: 0x06000012 RID: 18 RVA: 0x000024FA File Offset: 0x000008FA
public void SetQuality(int quality)
{
if (quality < 1)
{
quality = 1;
}
this.sample = quality;
}
// Token: 0x06000013 RID: 19 RVA: 0x00002510 File Offset: 0x00000910
public void SetSize(int w, int h)
{
if (!this.started || this.firstFrame)
{
this.width = w;
this.height = h;
if (this.width < 1)
{
this.width = 320;
}
if (this.height < 1)
{
this.height = 240;
}
this.sizeSet = true;
}
}
// Token: 0x06000014 RID: 20 RVA: 0x0000257C File Offset: 0x0000097C
public bool Start(Stream os)
{
bool flag;
if (os == null)
{
flag = false;
}
else
{
this.closeStream = false;
this.gifStream = os;
try
{
this.WriteString("GIF89a");
}
catch (IOException ex)
{
throw ex;
}
bool flag2 = this.WriteTemp();
flag = (this.started = flag2);
}
return flag;
}
// Token: 0x06000015 RID: 21 RVA: 0x000025E8 File Offset: 0x000009E8
public bool Start(string file)
{
bool flag = true;
try
{
this.gifStream = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
flag = this.Start(this.tempStream);
this.closeStream = true;
}
catch (IOException ex)
{
throw ex;
}
return this.started = flag;
}
// Token: 0x06000016 RID: 22 RVA: 0x00002648 File Offset: 0x00000A48
protected void AnalyzePixels()
{
int num = this.pixels.Length;
int num2 = num / 3;
this.indexedPixels = new byte[num2];
if (this.nq == null || !this.useStaticColorPalette)
{
this.nq = new NeuQuant(this.pixels, num, this.sample, this.paletteSize);
this.colorTab = this.nq.Process();
}
int num3 = 0;
for (int i = 0; i < num2; i++)
{
int num4 = this.nq.Map((int)(this.pixels[num3++] & byte.MaxValue), (int)(this.pixels[num3++] & byte.MaxValue), (int)(this.pixels[num3++] & byte.MaxValue));
this.usedEntry[num4] = true;
this.indexedPixels[i] = (byte)num4;
}
this.pixels = null;
this.colorDepth = 8;
this.palSize = 7;
if (this.transparent.Equals(default(Color32)))
{
this.transIndex = this.FindClosest(this.transparent);
}
}
// Token: 0x06000017 RID: 23 RVA: 0x00002774 File Offset: 0x00000B74
protected int FindClosest(Color32 c)
{
int num;
if (this.colorTab == null)
{
num = -1;
}
else
{
int r = (int)c.r;
int g = (int)c.g;
int b = (int)c.b;
int num2 = 0;
int num3 = 16777216;
int num4 = this.colorTab.Length;
for (int i = 0; i < num4; i++)
{
int num5 = r - (int)(this.colorTab[i++] & byte.MaxValue);
int num6 = g - (int)(this.colorTab[i++] & byte.MaxValue);
int num7 = b - (int)(this.colorTab[i] & byte.MaxValue);
int num8 = num5 * num5 + num6 * num6 + num7 * num7;
int num9 = i / 3;
if (this.usedEntry[num9] && num8 < num3)
{
num3 = num8;
num2 = num9;
}
}
num = num2;
}
return num;
}
// Token: 0x06000018 RID: 24 RVA: 0x00002860 File Offset: 0x00000C60
protected void GetImagePixels()
{
int num = this.image.width;
int num2 = this.image.height;
if (num != this.width || num2 != this.height)
{
Image image = new Image(this.width, this.height);
throw new NotImplementedException("meh");
}
this.pixels = new byte[3 * this.image.width * this.image.height];
int num3 = 0;
for (int i = 0; i < this.image.height; i++)
{
for (int j = 0; j < this.image.width; j++)
{
Color32 color = this.image[j, i];
this.pixels[num3] = color.r;
num3++;
this.pixels[num3] = color.g;
num3++;
this.pixels[num3] = color.b;
num3++;
}
}
}
// Token: 0x06000019 RID: 25 RVA: 0x00002970 File Offset: 0x00000D70
protected void WriteGraphicCtrlExt()
{
this.tempStream.WriteByte(33);
this.tempStream.WriteByte(249);
this.tempStream.WriteByte(4);
int num;
int num2;
if (this.transparent.Equals(default(Color32)))
{
num = 0;
num2 = 0;
}
else
{
num = 1;
num2 = 2;
}
if (this.dispose >= 0)
{
num2 = this.dispose & 7;
}
num2 <<= 2;
this.tempStream.WriteByte(Convert.ToByte(0 | num2 | 0 | num));
this.WriteShort(this.delay);
this.tempStream.WriteByte(Convert.ToByte(this.transIndex));
this.tempStream.WriteByte(0);
}
// Token: 0x0600001A RID: 26 RVA: 0x00002A3C File Offset: 0x00000E3C
protected void WriteImageDesc(bool localPalette)
{
this.tempStream.WriteByte(44);
this.WriteShort(0);
this.WriteShort(0);
this.WriteShort(this.width);
this.WriteShort(this.height);
if (this.firstFrame)
{
this.tempStream.WriteByte(0);
}
else
{
this.tempStream.WriteByte(Convert.ToByte(((!localPalette) ? 0 : 128) | 0 | 0 | 0 | this.palSize));
}
}
// Token: 0x0600001B RID: 27 RVA: 0x00002ACC File Offset: 0x00000ECC
protected void WriteLSD()
{
this.WriteShort(this.width);
this.WriteShort(this.height);
this.tempStream.WriteByte(Convert.ToByte(240 | this.palSize));
this.tempStream.WriteByte(0);
this.tempStream.WriteByte(0);
}
// Token: 0x0600001C RID: 28 RVA: 0x00002B28 File Offset: 0x00000F28
protected void WriteNetscapeExt()
{
this.tempStream.WriteByte(33);
this.tempStream.WriteByte(byte.MaxValue);
this.tempStream.WriteByte(11);
this.WriteString("NETSCAPE2.0");
this.tempStream.WriteByte(3);
this.tempStream.WriteByte(1);
this.WriteShort(this.repeat);
this.tempStream.WriteByte(0);
}
// Token: 0x0600001D RID: 29 RVA: 0x00002B9C File Offset: 0x00000F9C
protected void WritePalette()
{
this.tempStream.Write(this.colorTab, 0, this.colorTab.Length);
int num = 768 - this.colorTab.Length;
for (int i = 0; i < num; i++)
{
this.tempStream.WriteByte(0);
}
}
// Token: 0x0600001E RID: 30 RVA: 0x00002BF4 File Offset: 0x00000FF4
protected void WritePixels()
{
LZWEncoder lzwencoder = new LZWEncoder(this.width, this.height, this.indexedPixels, this.colorDepth);
lzwencoder.Encode(this.tempStream);
}
// Token: 0x0600001F RID: 31 RVA: 0x00002C2C File Offset: 0x0000102C
protected void WriteShort(int value)
{
this.tempStream.WriteByte(Convert.ToByte(value & 255));
this.tempStream.WriteByte(Convert.ToByte((value >> 8) & 255));
}
// Token: 0x06000020 RID: 32 RVA: 0x00002C60 File Offset: 0x00001060
protected void WriteString(string s)
{
char[] array = s.ToCharArray();
for (int i = 0; i < array.Length; i++)
{
this.tempStream.WriteByte((byte)array[i]);
}
}
// Token: 0x04000004 RID: 4
protected int width;
// Token: 0x04000005 RID: 5
protected int height;
// Token: 0x04000006 RID: 6
protected Color32 transparent = new Color32(0, 0, 0, 0);
// Token: 0x04000007 RID: 7
protected int transIndex;
// Token: 0x04000008 RID: 8
protected int repeat = -1;
// Token: 0x04000009 RID: 9
protected int delay = 0;
// Token: 0x0400000A RID: 10
protected bool started = false;
// Token: 0x0400000B RID: 11
protected MemoryStream tempStream = new MemoryStream();
// Token: 0x0400000C RID: 12
protected Stream gifStream;
// Token: 0x0400000D RID: 13
protected int paletteSize = 256;
// Token: 0x0400000E RID: 14
protected Image image;
// Token: 0x0400000F RID: 15
protected byte[] pixels;
// Token: 0x04000010 RID: 16
protected byte[] indexedPixels;
// Token: 0x04000011 RID: 17
protected int colorDepth;
// Token: 0x04000012 RID: 18
protected byte[] colorTab;
// Token: 0x04000013 RID: 19
protected bool[] usedEntry = new bool[256];
// Token: 0x04000014 RID: 20
protected int palSize = 7;
// Token: 0x04000015 RID: 21
protected int dispose = -1;
// Token: 0x04000016 RID: 22
protected bool closeStream = false;
// Token: 0x04000017 RID: 23
protected bool firstFrame = true;
// Token: 0x04000018 RID: 24
protected bool sizeSet = false;
// Token: 0x04000019 RID: 25
protected int sample = 10;
// Token: 0x0400001A RID: 26
protected long maxSize = long.MaxValue;
// Token: 0x0400001B RID: 27
protected bool limitFileSize = false;
// Token: 0x0400001C RID: 28
protected long bytesWritten = 0L;
// Token: 0x0400001D RID: 29
protected bool useStaticColorPalette;
// Token: 0x0400001E RID: 30
private NeuQuant nq;
}
}
+60
View File
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{99604A24-13D0-4C83-A3AA-9A315339FA45}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Gif.Components</RootNamespace>
<AssemblyName>Gif.Components</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
</PropertyGroup>
<ItemGroup />
<ItemGroup>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Include="AnimatedGifEncoder.cs" />
<Compile Include="GifDecoder.cs" />
<Compile Include="Image.cs" />
<Compile Include="LZWEncoder.cs" />
<Compile Include="NeuQuant.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rectangle.cs" />
<Compile Include="Size.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\mscorlib\mscorlib.csproj">
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa4c}</Project>
<Name>mscorlib</Name>
</ProjectReference>
<ProjectReference Include="..\UnityEngine\UnityEngine.csproj">
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa58}</Project>
<Name>UnityEngine</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+814
View File
@@ -0,0 +1,814 @@
using System;
using System.Collections;
using System.IO;
using UnityEngine;
namespace Gif.Components
{
// Token: 0x02000006 RID: 6
public class GifDecoder
{
// Token: 0x06000023 RID: 35 RVA: 0x00002CFC File Offset: 0x000010FC
public int GetDelay(int n)
{
this.delay = -1;
if (n >= 0 && n < this.frameCount)
{
this.delay = ((GifDecoder.GifFrame)this.frames[n]).delay;
}
return this.delay;
}
// Token: 0x06000024 RID: 36 RVA: 0x00002D50 File Offset: 0x00001150
public int GetFrameCount()
{
return this.frameCount;
}
// Token: 0x06000025 RID: 37 RVA: 0x00002D6C File Offset: 0x0000116C
public Image GetImage()
{
return this.GetFrame(0);
}
// Token: 0x06000026 RID: 38 RVA: 0x00002D88 File Offset: 0x00001188
public int GetLoopCount()
{
return this.loopCount;
}
// Token: 0x06000027 RID: 39 RVA: 0x00002DA4 File Offset: 0x000011A4
private int[] GetPixels(Image bitmap)
{
int[] array = new int[3 * this.image.width * this.image.height];
int num = 0;
for (int i = 0; i < this.image.height; i++)
{
for (int j = 0; j < this.image.width; j++)
{
Color32 color = bitmap[j, i];
array[num] = (int)color.r;
num++;
array[num] = (int)color.g;
num++;
array[num] = (int)color.b;
num++;
}
}
return array;
}
// Token: 0x06000028 RID: 40 RVA: 0x00002E50 File Offset: 0x00001250
private void SetPixels(int[] pixels)
{
int num = 0;
for (int i = 0; i < this.image.height; i++)
{
for (int j = 0; j < this.image.width; j++)
{
int num2 = pixels[num++];
byte b = (byte)((num2 >> 16) & 255);
byte b2 = (byte)((num2 >> 8) & 255);
byte b3 = (byte)((num2 >> 0) & 255);
byte b4 = (byte)((num2 >> 24) & 255);
Color32 color = new Color32(b, b2, b3, b4);
this.bitmap[j, i] = color;
}
}
}
// Token: 0x06000029 RID: 41 RVA: 0x00002EF4 File Offset: 0x000012F4
protected void SetPixels()
{
int[] array = this.GetPixels(this.bitmap);
if (this.lastDispose > 0)
{
if (this.lastDispose == 3)
{
int num = this.frameCount - 2;
if (num > 0)
{
this.lastImage = this.GetFrame(num - 1);
}
else
{
this.lastImage = null;
}
}
if (this.lastImage != null)
{
int[] array2 = this.GetPixels(this.lastImage);
Array.Copy(array2, 0, array, 0, this.width * this.height);
if (this.lastDispose == 2)
{
Color32 color = default(Color32);
if (this.transparency)
{
color = new Color32(0, 0, 0, 0);
}
else
{
int num2 = this.lastBgColor;
byte b = (byte)((num2 >> 16) & 255);
byte b2 = (byte)((num2 >> 8) & 255);
byte b3 = (byte)((num2 >> 0) & 255);
byte b4 = (byte)((num2 >> 24) & 255);
color = new Color32(b, b2, b3, b4);
}
this.image.Fill(color, this.lastRect.xmin, this.lastRect.ymin, this.lastRect.xmax, this.lastRect.ymax);
}
}
}
int num3 = 1;
int num4 = 8;
int num5 = 0;
for (int i = 0; i < this.ih; i++)
{
int num6 = i;
if (this.interlace)
{
if (num5 >= this.ih)
{
num3++;
if (num3 != 2)
{
if (num3 != 3)
{
if (num3 == 4)
{
num5 = 1;
num4 = 2;
}
}
else
{
num5 = 2;
num4 = 4;
}
}
else
{
num5 = 4;
}
}
num6 = num5;
num5 += num4;
}
num6 += this.iy;
if (num6 < this.height)
{
int num7 = num6 * this.width;
int j = num7 + this.ix;
int num8 = j + this.iw;
if (num7 + this.width < num8)
{
num8 = num7 + this.width;
}
int num9 = i * this.iw;
while (j < num8)
{
int num10 = (int)(this.pixels[num9++] & byte.MaxValue);
int num11 = this.act[num10];
if (num11 != 0)
{
array[j] = num11;
}
j++;
}
}
}
this.SetPixels(array);
}
// Token: 0x0600002A RID: 42 RVA: 0x00003188 File Offset: 0x00001588
public Image GetFrame(int n)
{
Image image = null;
if (n >= 0 && n < this.frameCount)
{
image = ((GifDecoder.GifFrame)this.frames[n]).image;
}
return image;
}
// Token: 0x0600002B RID: 43 RVA: 0x000031CC File Offset: 0x000015CC
public Size GetFrameSize()
{
return new Size(this.width, this.height);
}
// Token: 0x0600002C RID: 44 RVA: 0x000031F4 File Offset: 0x000015F4
public int Read(Stream inStream)
{
this.Init();
if (inStream != null)
{
this.inStream = inStream;
this.ReadHeader();
if (!this.Error())
{
this.ReadContents();
if (this.frameCount < 0)
{
this.status = GifDecoder.STATUS_FORMAT_ERROR;
}
}
inStream.Close();
}
else
{
this.status = GifDecoder.STATUS_OPEN_ERROR;
}
return this.status;
}
// Token: 0x0600002D RID: 45 RVA: 0x00003270 File Offset: 0x00001670
public int Read(string name)
{
this.status = GifDecoder.STATUS_OK;
try
{
name = name.Trim().ToLower();
this.status = this.Read(new FileInfo(name).OpenRead());
}
catch (IOException ex)
{
this.status = GifDecoder.STATUS_OPEN_ERROR;
}
return this.status;
}
// Token: 0x0600002E RID: 46 RVA: 0x000032E4 File Offset: 0x000016E4
protected void DecodeImageData()
{
int num = -1;
int num2 = this.iw * this.ih;
if (this.pixels == null || this.pixels.Length < num2)
{
this.pixels = new byte[num2];
}
if (this.prefix == null)
{
this.prefix = new short[GifDecoder.MaxStackSize];
}
if (this.suffix == null)
{
this.suffix = new byte[GifDecoder.MaxStackSize];
}
if (this.pixelStack == null)
{
this.pixelStack = new byte[GifDecoder.MaxStackSize + 1];
}
int num3 = this.Read();
int num4 = 1 << num3;
int num5 = num4 + 1;
int num6 = num4 + 2;
int num7 = num;
int num8 = num3 + 1;
int num9 = (1 << num8) - 1;
for (int i = 0; i < num4; i++)
{
this.prefix[i] = 0;
this.suffix[i] = (byte)i;
}
int num16;
int num15;
int num14;
int num13;
int num12;
int num11;
int num10 = (num11 = (num12 = (num13 = (num14 = (num15 = (num16 = 0))))));
for (int j = 0; j < num2; j++)
{
if (num14 == 0)
{
if (num10 < num8)
{
if (num12 == 0)
{
num12 = this.ReadBlock();
if (num12 <= 0)
{
break;
}
num16 = 0;
}
num11 += (int)(this.block[num16] & byte.MaxValue) << num10;
num10 += 8;
num16++;
num12--;
continue;
}
int i = num11 & num9;
num11 >>= num8;
num10 -= num8;
if (i > num6 || i == num5)
{
break;
}
if (i == num4)
{
num8 = num3 + 1;
num9 = (1 << num8) - 1;
num6 = num4 + 2;
num7 = num;
continue;
}
if (num7 == num)
{
this.pixelStack[num14++] = this.suffix[i];
num7 = i;
num13 = i;
continue;
}
int num17 = i;
if (i == num6)
{
this.pixelStack[num14++] = (byte)num13;
i = num7;
}
while (i > num4)
{
this.pixelStack[num14++] = this.suffix[i];
i = (int)this.prefix[i];
}
num13 = (int)(this.suffix[i] & byte.MaxValue);
if (num6 >= GifDecoder.MaxStackSize)
{
break;
}
this.pixelStack[num14++] = (byte)num13;
this.prefix[num6] = (short)num7;
this.suffix[num6] = (byte)num13;
num6++;
if ((num6 & num9) == 0 && num6 < GifDecoder.MaxStackSize)
{
num8++;
num9 += num6;
}
num7 = num17;
}
num14--;
this.pixels[num15++] = this.pixelStack[num14];
}
for (int j = num15; j < num2; j++)
{
this.pixels[j] = 0;
}
}
// Token: 0x0600002F RID: 47 RVA: 0x000035F0 File Offset: 0x000019F0
protected bool Error()
{
return this.status != GifDecoder.STATUS_OK;
}
// Token: 0x06000030 RID: 48 RVA: 0x00003615 File Offset: 0x00001A15
protected void Init()
{
this.status = GifDecoder.STATUS_OK;
this.frameCount = 0;
this.frames = new ArrayList();
this.gct = null;
this.lct = null;
}
// Token: 0x06000031 RID: 49 RVA: 0x00003644 File Offset: 0x00001A44
protected int Read()
{
int num = 0;
try
{
num = this.inStream.ReadByte();
}
catch (IOException ex)
{
this.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return num;
}
// Token: 0x06000032 RID: 50 RVA: 0x00003694 File Offset: 0x00001A94
protected int ReadBlock()
{
this.blockSize = this.Read();
int i = 0;
if (this.blockSize > 0)
{
try
{
while (i < this.blockSize)
{
int num = this.inStream.Read(this.block, i, this.blockSize - i);
if (num == -1)
{
break;
}
i += num;
}
}
catch (IOException ex)
{
}
if (i < this.blockSize)
{
this.status = GifDecoder.STATUS_FORMAT_ERROR;
}
}
return i;
}
// Token: 0x06000033 RID: 51 RVA: 0x00003740 File Offset: 0x00001B40
protected int[] ReadColorTable(int ncolors)
{
int num = 3 * ncolors;
int[] array = null;
byte[] array2 = new byte[num];
int num2 = 0;
try
{
num2 = this.inStream.Read(array2, 0, array2.Length);
}
catch (IOException ex)
{
}
if (num2 < num)
{
this.status = GifDecoder.STATUS_FORMAT_ERROR;
}
else
{
array = new int[256];
int i = 0;
int num3 = 0;
while (i < ncolors)
{
int num4 = (int)(array2[num3++] & byte.MaxValue);
int num5 = (int)(array2[num3++] & byte.MaxValue);
int num6 = (int)(array2[num3++] & byte.MaxValue);
array[i++] = (int)((ulong)(-16777216) | (ulong)((long)((long)num4 << 16)) | (ulong)((long)((long)num5 << 8)) | (ulong)((long)num6));
}
}
return array;
}
// Token: 0x06000034 RID: 52 RVA: 0x00003828 File Offset: 0x00001C28
protected void ReadContents()
{
bool flag = false;
while (!flag && !this.Error())
{
int num = this.Read();
if (num != 0)
{
if (num != 33)
{
if (num != 44)
{
if (num != 59)
{
this.status = GifDecoder.STATUS_FORMAT_ERROR;
}
else
{
flag = true;
}
}
else
{
this.ReadImage();
}
}
else
{
num = this.Read();
if (num != 249)
{
if (num != 255)
{
this.Skip();
}
else
{
this.ReadBlock();
string text = "";
for (int i = 0; i < 11; i++)
{
text += (char)this.block[i];
}
if (text.Equals("NETSCAPE2.0"))
{
this.ReadNetscapeExt();
}
else
{
this.Skip();
}
}
}
else
{
this.ReadGraphicControlExt();
}
}
}
}
}
// Token: 0x06000035 RID: 53 RVA: 0x00003940 File Offset: 0x00001D40
protected void ReadGraphicControlExt()
{
this.Read();
int num = this.Read();
this.dispose = (num & 28) >> 2;
if (this.dispose == 0)
{
this.dispose = 1;
}
this.transparency = (num & 1) != 0;
this.delay = this.ReadShort() * 10;
this.transIndex = this.Read();
this.Read();
}
// Token: 0x06000036 RID: 54 RVA: 0x000039B0 File Offset: 0x00001DB0
protected void ReadHeader()
{
string text = "";
for (int i = 0; i < 6; i++)
{
text += (char)this.Read();
}
if (!text.StartsWith("GIF"))
{
this.status = GifDecoder.STATUS_FORMAT_ERROR;
}
else
{
this.ReadLSD();
if (this.gctFlag && !this.Error())
{
this.gct = this.ReadColorTable(this.gctSize);
this.bgColor = this.gct[this.bgIndex];
}
}
}
// Token: 0x06000037 RID: 55 RVA: 0x00003A50 File Offset: 0x00001E50
protected void ReadImage()
{
this.ix = this.ReadShort();
this.iy = this.ReadShort();
this.iw = this.ReadShort();
this.ih = this.ReadShort();
int num = this.Read();
this.lctFlag = (num & 128) != 0;
this.interlace = (num & 64) != 0;
this.lctSize = 2 << (num & 7);
if (this.lctFlag)
{
this.lct = this.ReadColorTable(this.lctSize);
this.act = this.lct;
}
else
{
this.act = this.gct;
if (this.bgIndex == this.transIndex)
{
this.bgColor = 0;
}
}
int num2 = 0;
if (this.transparency)
{
num2 = this.act[this.transIndex];
this.act[this.transIndex] = 0;
}
if (this.act == null)
{
this.status = GifDecoder.STATUS_FORMAT_ERROR;
}
if (!this.Error())
{
this.DecodeImageData();
this.Skip();
if (!this.Error())
{
this.frameCount++;
this.bitmap = new Image(this.width, this.height);
this.image = this.bitmap;
this.SetPixels();
this.frames.Add(new GifDecoder.GifFrame(this.bitmap, this.delay));
if (this.transparency)
{
this.act[this.transIndex] = num2;
}
this.ResetFrame();
}
}
}
// Token: 0x06000038 RID: 56 RVA: 0x00003C00 File Offset: 0x00002000
protected void ReadLSD()
{
this.width = this.ReadShort();
this.height = this.ReadShort();
int num = this.Read();
this.gctFlag = (num & 128) != 0;
this.gctSize = 2 << (num & 7);
this.bgIndex = this.Read();
this.pixelAspect = this.Read();
}
// Token: 0x06000039 RID: 57 RVA: 0x00003C68 File Offset: 0x00002068
protected void ReadNetscapeExt()
{
do
{
this.ReadBlock();
if (this.block[0] == 1)
{
int num = (int)(this.block[1] & byte.MaxValue);
int num2 = (int)(this.block[2] & byte.MaxValue);
this.loopCount = (num2 << 8) | num;
}
}
while (this.blockSize > 0 && !this.Error());
}
// Token: 0x0600003A RID: 58 RVA: 0x00003CD0 File Offset: 0x000020D0
protected int ReadShort()
{
return this.Read() | (this.Read() << 8);
}
// Token: 0x0600003B RID: 59 RVA: 0x00003CF4 File Offset: 0x000020F4
protected void ResetFrame()
{
this.lastDispose = this.dispose;
this.lastRect = new Rectangle
{
xmin = this.ix,
ymin = this.iy,
xmax = this.ix + this.iw,
ymax = this.iy + this.ih
};
this.lastImage = this.image;
this.lastBgColor = this.bgColor;
this.lct = null;
}
// Token: 0x0600003C RID: 60 RVA: 0x00003D82 File Offset: 0x00002182
protected void Skip()
{
do
{
this.ReadBlock();
}
while (this.blockSize > 0 && !this.Error());
}
// Token: 0x04000025 RID: 37
public static readonly int STATUS_OK = 0;
// Token: 0x04000026 RID: 38
public static readonly int STATUS_FORMAT_ERROR = 1;
// Token: 0x04000027 RID: 39
public static readonly int STATUS_OPEN_ERROR = 2;
// Token: 0x04000028 RID: 40
protected Stream inStream;
// Token: 0x04000029 RID: 41
protected int status;
// Token: 0x0400002A RID: 42
protected int width;
// Token: 0x0400002B RID: 43
protected int height;
// Token: 0x0400002C RID: 44
protected bool gctFlag;
// Token: 0x0400002D RID: 45
protected int gctSize;
// Token: 0x0400002E RID: 46
protected int loopCount = 1;
// Token: 0x0400002F RID: 47
protected int[] gct;
// Token: 0x04000030 RID: 48
protected int[] lct;
// Token: 0x04000031 RID: 49
protected int[] act;
// Token: 0x04000032 RID: 50
protected int bgIndex;
// Token: 0x04000033 RID: 51
protected int bgColor;
// Token: 0x04000034 RID: 52
protected int lastBgColor;
// Token: 0x04000035 RID: 53
protected int pixelAspect;
// Token: 0x04000036 RID: 54
protected bool lctFlag;
// Token: 0x04000037 RID: 55
protected bool interlace;
// Token: 0x04000038 RID: 56
protected int lctSize;
// Token: 0x04000039 RID: 57
protected int ix;
// Token: 0x0400003A RID: 58
protected int iy;
// Token: 0x0400003B RID: 59
protected int iw;
// Token: 0x0400003C RID: 60
protected int ih;
// Token: 0x0400003D RID: 61
protected Rectangle lastRect;
// Token: 0x0400003E RID: 62
protected Image image;
// Token: 0x0400003F RID: 63
protected Image bitmap;
// Token: 0x04000040 RID: 64
protected Image lastImage;
// Token: 0x04000041 RID: 65
protected byte[] block = new byte[256];
// Token: 0x04000042 RID: 66
protected int blockSize = 0;
// Token: 0x04000043 RID: 67
protected int dispose = 0;
// Token: 0x04000044 RID: 68
protected int lastDispose = 0;
// Token: 0x04000045 RID: 69
protected bool transparency = false;
// Token: 0x04000046 RID: 70
protected int delay = 0;
// Token: 0x04000047 RID: 71
protected int transIndex;
// Token: 0x04000048 RID: 72
protected static readonly int MaxStackSize = 4096;
// Token: 0x04000049 RID: 73
protected short[] prefix;
// Token: 0x0400004A RID: 74
protected byte[] suffix;
// Token: 0x0400004B RID: 75
protected byte[] pixelStack;
// Token: 0x0400004C RID: 76
protected byte[] pixels;
// Token: 0x0400004D RID: 77
protected ArrayList frames;
// Token: 0x0400004E RID: 78
protected int frameCount;
// Token: 0x02000007 RID: 7
public class GifFrame
{
// Token: 0x0600003E RID: 62 RVA: 0x00003DC3 File Offset: 0x000021C3
public GifFrame(Image im, int del)
{
this.image = im;
this.delay = del;
}
// Token: 0x0400004F RID: 79
public Image image;
// Token: 0x04000050 RID: 80
public int delay;
}
}
}
+61
View File
@@ -0,0 +1,61 @@
using System;
using UnityEngine;
namespace Gif.Components
{
// Token: 0x02000002 RID: 2
public class Image
{
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000450
public Image(int width, int height)
{
this.width = width;
this.height = height;
this.colors = new Color32[width * height];
}
// Token: 0x06000002 RID: 2 RVA: 0x00002075 File Offset: 0x00000475
public Image(Texture2D tex)
{
this.width = tex.width;
this.height = tex.height;
this.colors = tex.GetPixels32();
}
// Token: 0x17000001 RID: 1
public Color32 this[int col, int row]
{
get
{
int num = col + (this.height - row - 1) * this.width;
return this.colors[num];
}
set
{
int num = col + (this.height - row - 1) * this.width;
this.colors[num] = value;
}
}
// Token: 0x06000005 RID: 5 RVA: 0x00002114 File Offset: 0x00000514
public void Fill(Color32 c, int xmin, int ymin, int xmax, int ymax)
{
for (int i = ymin; i <= ymax; i++)
{
for (int j = xmin; j <= xmax; j++)
{
this[j, i] = c;
}
}
}
// Token: 0x04000001 RID: 1
public int width;
// Token: 0x04000002 RID: 2
public int height;
// Token: 0x04000003 RID: 3
public Color32[] colors;
}
}
+310
View File
@@ -0,0 +1,310 @@
using System;
using System.IO;
namespace Gif.Components
{
// Token: 0x02000008 RID: 8
public class LZWEncoder
{
// Token: 0x0600003F RID: 63 RVA: 0x00003DDC File Offset: 0x000021DC
public LZWEncoder(int width, int height, byte[] pixels, int color_depth)
{
this.imgW = width;
this.imgH = height;
this.pixAry = pixels;
this.initCodeSize = Math.Max(2, color_depth);
}
// Token: 0x06000040 RID: 64 RVA: 0x00003EA0 File Offset: 0x000022A0
private void Add(byte c, Stream outs)
{
this.accum[this.a_count++] = c;
if (this.a_count >= 254)
{
this.Flush(outs);
}
}
// Token: 0x06000041 RID: 65 RVA: 0x00003EDE File Offset: 0x000022DE
private void ClearTable(Stream outs)
{
this.ResetCodeTable(this.hsize);
this.free_ent = this.ClearCode + 2;
this.clear_flg = true;
this.Output(this.ClearCode, outs);
}
// Token: 0x06000042 RID: 66 RVA: 0x00003F10 File Offset: 0x00002310
private void ResetCodeTable(int hsize)
{
for (int i = 0; i < hsize; i++)
{
this.htab[i] = -1;
}
}
// Token: 0x06000043 RID: 67 RVA: 0x00003F3C File Offset: 0x0000233C
private void Compress(int init_bits, Stream outs)
{
this.g_init_bits = init_bits;
this.clear_flg = false;
this.n_bits = this.g_init_bits;
this.maxcode = this.MaxCode(this.n_bits);
this.ClearCode = 1 << init_bits - 1;
this.EOFCode = this.ClearCode + 1;
this.free_ent = this.ClearCode + 2;
this.a_count = 0;
int num = this.NextPixel();
int num2 = 0;
for (int i = this.hsize; i < 65536; i *= 2)
{
num2++;
}
num2 = 8 - num2;
int num3 = this.hsize;
this.ResetCodeTable(num3);
this.Output(this.ClearCode, outs);
for (;;)
{
int num4;
while ((num4 = this.NextPixel()) != LZWEncoder.EOF)
{
int i = (num4 << this.maxbits) + num;
int num5 = (num4 << num2) ^ num;
if (this.htab[num5] == i)
{
num = this.codetab[num5];
}
else
{
if (this.htab[num5] >= 0)
{
int num6 = num3 - num5;
if (num5 == 0)
{
num6 = 1;
}
for (;;)
{
if ((num5 -= num6) < 0)
{
num5 += num3;
}
if (this.htab[num5] == i)
{
break;
}
if (this.htab[num5] < 0)
{
goto IL_144;
}
}
num = this.codetab[num5];
continue;
}
IL_144:
this.Output(num, outs);
num = num4;
if (this.free_ent < this.maxmaxcode)
{
this.codetab[num5] = this.free_ent++;
this.htab[num5] = i;
}
else
{
this.ClearTable(outs);
}
}
}
break;
}
this.Output(num, outs);
this.Output(this.EOFCode, outs);
}
// Token: 0x06000044 RID: 68 RVA: 0x00004104 File Offset: 0x00002504
public void Encode(Stream os)
{
os.WriteByte(Convert.ToByte(this.initCodeSize));
this.remaining = this.imgW * this.imgH;
this.curPixel = 0;
this.Compress(this.initCodeSize + 1, os);
os.WriteByte(0);
}
// Token: 0x06000045 RID: 69 RVA: 0x00004153 File Offset: 0x00002553
private void Flush(Stream outs)
{
if (this.a_count > 0)
{
outs.WriteByte(Convert.ToByte(this.a_count));
outs.Write(this.accum, 0, this.a_count);
this.a_count = 0;
}
}
// Token: 0x06000046 RID: 70 RVA: 0x00004190 File Offset: 0x00002590
private int MaxCode(int n_bits)
{
return (1 << n_bits) - 1;
}
// Token: 0x06000047 RID: 71 RVA: 0x000041B0 File Offset: 0x000025B0
private int NextPixel()
{
int num;
if (this.remaining == 0)
{
num = LZWEncoder.EOF;
}
else
{
this.remaining--;
int num2 = this.curPixel + 1;
if (num2 < this.pixAry.GetUpperBound(0))
{
byte b = this.pixAry[this.curPixel++];
num = (int)(b & byte.MaxValue);
}
else
{
num = 255;
}
}
return num;
}
// Token: 0x06000048 RID: 72 RVA: 0x00004230 File Offset: 0x00002630
private void Output(int code, Stream outs)
{
this.cur_accum &= this.masks[this.cur_bits];
if (this.cur_bits > 0)
{
this.cur_accum |= code << this.cur_bits;
}
else
{
this.cur_accum = code;
}
this.cur_bits += this.n_bits;
while (this.cur_bits >= 8)
{
this.Add((byte)(this.cur_accum & 255), outs);
this.cur_accum >>= 8;
this.cur_bits -= 8;
}
if (this.free_ent > this.maxcode || this.clear_flg)
{
if (this.clear_flg)
{
this.maxcode = this.MaxCode(this.n_bits = this.g_init_bits);
this.clear_flg = false;
}
else
{
this.n_bits++;
if (this.n_bits == this.maxbits)
{
this.maxcode = this.maxmaxcode;
}
else
{
this.maxcode = this.MaxCode(this.n_bits);
}
}
}
if (code == this.EOFCode)
{
while (this.cur_bits > 0)
{
this.Add((byte)(this.cur_accum & 255), outs);
this.cur_accum >>= 8;
this.cur_bits -= 8;
}
this.Flush(outs);
}
}
// Token: 0x04000051 RID: 81
private static readonly int EOF = -1;
// Token: 0x04000052 RID: 82
private int imgW;
// Token: 0x04000053 RID: 83
private int imgH;
// Token: 0x04000054 RID: 84
private byte[] pixAry;
// Token: 0x04000055 RID: 85
private int initCodeSize;
// Token: 0x04000056 RID: 86
private int remaining;
// Token: 0x04000057 RID: 87
private int curPixel;
// Token: 0x04000058 RID: 88
private static readonly int BITS = 12;
// Token: 0x04000059 RID: 89
private static readonly int HSIZE = 5003;
// Token: 0x0400005A RID: 90
private int n_bits;
// Token: 0x0400005B RID: 91
private int maxbits = LZWEncoder.BITS;
// Token: 0x0400005C RID: 92
private int maxcode;
// Token: 0x0400005D RID: 93
private int maxmaxcode = 1 << LZWEncoder.BITS;
// Token: 0x0400005E RID: 94
private int[] htab = new int[LZWEncoder.HSIZE];
// Token: 0x0400005F RID: 95
private int[] codetab = new int[LZWEncoder.HSIZE];
// Token: 0x04000060 RID: 96
private int hsize = LZWEncoder.HSIZE;
// Token: 0x04000061 RID: 97
private int free_ent = 0;
// Token: 0x04000062 RID: 98
private bool clear_flg = false;
// Token: 0x04000063 RID: 99
private int g_init_bits;
// Token: 0x04000064 RID: 100
private int ClearCode;
// Token: 0x04000065 RID: 101
private int EOFCode;
// Token: 0x04000066 RID: 102
private int cur_accum = 0;
// Token: 0x04000067 RID: 103
private int cur_bits = 0;
// Token: 0x04000068 RID: 104
private int[] masks = new int[]
{
0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
1023, 2047, 4095, 8191, 16383, 32767, 65535
};
// Token: 0x04000069 RID: 105
private int a_count;
// Token: 0x0400006A RID: 106
private byte[] accum = new byte[256];
}
}
+511
View File
@@ -0,0 +1,511 @@
using System;
namespace Gif.Components
{
// Token: 0x02000009 RID: 9
public class NeuQuant
{
// Token: 0x0600004A RID: 74 RVA: 0x000043E8 File Offset: 0x000027E8
public NeuQuant(byte[] thepic, int len, int sample, int paletteSize = 256)
{
this.netsize = paletteSize;
this.initrad = this.netsize >> 3;
this.maxnetpos = this.netsize - 1;
this.initradius = this.initrad * NeuQuant.radiusbias;
this.bias = new int[this.netsize];
this.freq = new int[this.netsize];
this.radpower = new int[this.initrad];
this.thepicture = thepic;
this.lengthcount = len;
this.samplefac = sample;
this.network = new int[this.netsize][];
for (int i = 0; i < this.netsize; i++)
{
this.network[i] = new int[4];
int[] array = this.network[i];
array[0] = (array[1] = (array[2] = (i << NeuQuant.netbiasshift + 8) / this.netsize));
this.freq[i] = NeuQuant.intbias / this.netsize;
this.bias[i] = 0;
}
}
// Token: 0x0600004B RID: 75 RVA: 0x0000450C File Offset: 0x0000290C
public byte[] ColorMap()
{
byte[] array = new byte[3 * this.netsize];
int[] array2 = new int[this.netsize];
for (int i = 0; i < this.netsize; i++)
{
array2[this.network[i][3]] = i;
}
int num = 0;
for (int j = 0; j < this.netsize; j++)
{
int num2 = array2[j];
array[num++] = (byte)this.network[num2][0];
array[num++] = (byte)this.network[num2][1];
array[num++] = (byte)this.network[num2][2];
}
return array;
}
// Token: 0x0600004C RID: 76 RVA: 0x000045C0 File Offset: 0x000029C0
public void Inxbuild()
{
int num = 0;
int num2 = 0;
for (int i = 0; i < this.netsize; i++)
{
int[] array = this.network[i];
int num3 = i;
int num4 = array[1];
int[] array2;
for (int j = i + 1; j < this.netsize; j++)
{
array2 = this.network[j];
if (array2[1] < num4)
{
num3 = j;
num4 = array2[1];
}
}
array2 = this.network[num3];
if (i != num3)
{
int j = array2[0];
array2[0] = array[0];
array[0] = j;
j = array2[1];
array2[1] = array[1];
array[1] = j;
j = array2[2];
array2[2] = array[2];
array[2] = j;
j = array2[3];
array2[3] = array[3];
array[3] = j;
}
if (num4 != num)
{
this.netindex[num] = num2 + i >> 1;
for (int j = num + 1; j < num4; j++)
{
this.netindex[j] = i;
}
num = num4;
num2 = i;
}
}
this.netindex[num] = num2 + this.maxnetpos >> 1;
for (int j = num + 1; j < 256; j++)
{
this.netindex[j] = this.maxnetpos;
}
}
// Token: 0x0600004D RID: 77 RVA: 0x0000470C File Offset: 0x00002B0C
public void Learn()
{
if (this.lengthcount < NeuQuant.minpicturebytes)
{
this.samplefac = 1;
}
this.alphadec = 30 + (this.samplefac - 1) / 3;
byte[] array = this.thepicture;
int num = 0;
int num2 = this.lengthcount;
int num3 = this.lengthcount / (3 * this.samplefac);
int num4 = num3 / NeuQuant.ncycles;
int num5 = NeuQuant.initalpha;
int num6 = this.initradius;
int num7 = num6 >> NeuQuant.radiusbiasshift;
if (num7 <= 1)
{
num7 = 0;
}
int i;
for (i = 0; i < num7; i++)
{
this.radpower[i] = num5 * ((num7 * num7 - i * i) * NeuQuant.radbias / (num7 * num7));
}
int num8;
if (this.lengthcount < NeuQuant.minpicturebytes)
{
num8 = 3;
}
else if (this.lengthcount % NeuQuant.prime1 != 0)
{
num8 = 3 * NeuQuant.prime1;
}
else if (this.lengthcount % NeuQuant.prime2 != 0)
{
num8 = 3 * NeuQuant.prime2;
}
else if (this.lengthcount % NeuQuant.prime3 != 0)
{
num8 = 3 * NeuQuant.prime3;
}
else
{
num8 = 3 * NeuQuant.prime4;
}
i = 0;
while (i < num3)
{
int num9 = (int)(array[num] & byte.MaxValue) << NeuQuant.netbiasshift;
int num10 = (int)(array[num + 1] & byte.MaxValue) << NeuQuant.netbiasshift;
int num11 = (int)(array[num + 2] & byte.MaxValue) << NeuQuant.netbiasshift;
int j = this.Contest(num9, num10, num11);
this.Altersingle(num5, j, num9, num10, num11);
if (num7 != 0)
{
this.Alterneigh(num7, j, num9, num10, num11);
}
num += num8;
if (num >= num2)
{
num -= this.lengthcount;
}
i++;
if (num4 == 0)
{
num4 = 1;
}
if (i % num4 == 0)
{
num5 -= num5 / this.alphadec;
num6 -= num6 / NeuQuant.radiusdec;
num7 = num6 >> NeuQuant.radiusbiasshift;
if (num7 <= 1)
{
num7 = 0;
}
for (j = 0; j < num7; j++)
{
this.radpower[j] = num5 * ((num7 * num7 - j * j) * NeuQuant.radbias / (num7 * num7));
}
}
}
}
// Token: 0x0600004E RID: 78 RVA: 0x0000496C File Offset: 0x00002D6C
public int Map(int b, int g, int r)
{
int num = 1000;
int num2 = -1;
int num3 = this.netindex[g];
int num4 = num3 - 1;
while (num3 < this.netsize || num4 >= 0)
{
if (num3 < this.netsize)
{
int[] array = this.network[num3];
int num5 = array[1] - g;
if (num5 >= num)
{
num3 = this.netsize;
}
else
{
num3++;
if (num5 < 0)
{
num5 = -num5;
}
int num6 = array[0] - b;
if (num6 < 0)
{
num6 = -num6;
}
num5 += num6;
if (num5 < num)
{
num6 = array[2] - r;
if (num6 < 0)
{
num6 = -num6;
}
num5 += num6;
if (num5 < num)
{
num = num5;
num2 = array[3];
}
}
}
}
if (num4 >= 0)
{
int[] array = this.network[num4];
int num5 = g - array[1];
if (num5 >= num)
{
num4 = -1;
}
else
{
num4--;
if (num5 < 0)
{
num5 = -num5;
}
int num6 = array[0] - b;
if (num6 < 0)
{
num6 = -num6;
}
num5 += num6;
if (num5 < num)
{
num6 = array[2] - r;
if (num6 < 0)
{
num6 = -num6;
}
num5 += num6;
if (num5 < num)
{
num = num5;
num2 = array[3];
}
}
}
}
}
return num2;
}
// Token: 0x0600004F RID: 79 RVA: 0x00004AC0 File Offset: 0x00002EC0
public byte[] Process()
{
this.Learn();
this.Unbiasnet();
this.Inxbuild();
return this.ColorMap();
}
// Token: 0x06000050 RID: 80 RVA: 0x00004AF0 File Offset: 0x00002EF0
public void Unbiasnet()
{
for (int i = 0; i < this.netsize; i++)
{
this.network[i][0] >>= NeuQuant.netbiasshift;
this.network[i][1] >>= NeuQuant.netbiasshift;
this.network[i][2] >>= NeuQuant.netbiasshift;
this.network[i][3] = i;
}
}
// Token: 0x06000051 RID: 81 RVA: 0x00004B70 File Offset: 0x00002F70
protected void Alterneigh(int rad, int i, int b, int g, int r)
{
int num = i - rad;
if (num < -1)
{
num = -1;
}
int num2 = i + rad;
if (num2 > this.netsize)
{
num2 = this.netsize;
}
int num3 = i + 1;
int num4 = i - 1;
int num5 = 1;
while (num3 < num2 || num4 > num)
{
int num6 = this.radpower[num5++];
if (num3 < num2)
{
int[] array = this.network[num3++];
try
{
array[0] -= num6 * (array[0] - b) / NeuQuant.alpharadbias;
array[1] -= num6 * (array[1] - g) / NeuQuant.alpharadbias;
array[2] -= num6 * (array[2] - r) / NeuQuant.alpharadbias;
}
catch (Exception ex)
{
}
}
if (num4 > num)
{
int[] array = this.network[num4--];
try
{
array[0] -= num6 * (array[0] - b) / NeuQuant.alpharadbias;
array[1] -= num6 * (array[1] - g) / NeuQuant.alpharadbias;
array[2] -= num6 * (array[2] - r) / NeuQuant.alpharadbias;
}
catch (Exception ex2)
{
}
}
}
}
// Token: 0x06000052 RID: 82 RVA: 0x00004CE4 File Offset: 0x000030E4
protected void Altersingle(int alpha, int i, int b, int g, int r)
{
int[] array = this.network[i];
array[0] -= alpha * (array[0] - b) / NeuQuant.initalpha;
array[1] -= alpha * (array[1] - g) / NeuQuant.initalpha;
array[2] -= alpha * (array[2] - r) / NeuQuant.initalpha;
}
// Token: 0x06000053 RID: 83 RVA: 0x00004D48 File Offset: 0x00003148
protected int Contest(int b, int g, int r)
{
int num = int.MaxValue;
int num2 = num;
int num3 = -1;
int num4 = num3;
for (int i = 0; i < this.netsize; i++)
{
int[] array = this.network[i];
int num5 = array[0] - b;
if (num5 < 0)
{
num5 = -num5;
}
int num6 = array[1] - g;
if (num6 < 0)
{
num6 = -num6;
}
num5 += num6;
num6 = array[2] - r;
if (num6 < 0)
{
num6 = -num6;
}
num5 += num6;
if (num5 < num)
{
num = num5;
num3 = i;
}
int num7 = num5 - (this.bias[i] >> NeuQuant.intbiasshift - NeuQuant.netbiasshift);
if (num7 < num2)
{
num2 = num7;
num4 = i;
}
int num8 = this.freq[i] >> NeuQuant.betashift;
this.freq[i] -= num8;
this.bias[i] += num8 << NeuQuant.gammashift;
}
this.freq[num3] += NeuQuant.beta;
this.bias[num3] -= NeuQuant.betagamma;
return num4;
}
// Token: 0x0400006B RID: 107
protected int netsize;
// Token: 0x0400006C RID: 108
protected static readonly int prime1 = 499;
// Token: 0x0400006D RID: 109
protected static readonly int prime2 = 491;
// Token: 0x0400006E RID: 110
protected static readonly int prime3 = 487;
// Token: 0x0400006F RID: 111
protected static readonly int prime4 = 503;
// Token: 0x04000070 RID: 112
protected static readonly int minpicturebytes = 3 * NeuQuant.prime4;
// Token: 0x04000071 RID: 113
protected int maxnetpos;
// Token: 0x04000072 RID: 114
protected static readonly int netbiasshift = 4;
// Token: 0x04000073 RID: 115
protected static readonly int ncycles = 100;
// Token: 0x04000074 RID: 116
protected static readonly int intbiasshift = 16;
// Token: 0x04000075 RID: 117
protected static readonly int intbias = 1 << NeuQuant.intbiasshift;
// Token: 0x04000076 RID: 118
protected static readonly int gammashift = 10;
// Token: 0x04000077 RID: 119
protected static readonly int gamma = 1 << NeuQuant.gammashift;
// Token: 0x04000078 RID: 120
protected static readonly int betashift = 10;
// Token: 0x04000079 RID: 121
protected static readonly int beta = NeuQuant.intbias >> NeuQuant.betashift;
// Token: 0x0400007A RID: 122
protected static readonly int betagamma = NeuQuant.intbias << NeuQuant.gammashift - NeuQuant.betashift;
// Token: 0x0400007B RID: 123
protected int initrad;
// Token: 0x0400007C RID: 124
protected static readonly int radiusbiasshift = 6;
// Token: 0x0400007D RID: 125
protected static readonly int radiusbias = 1 << NeuQuant.radiusbiasshift;
// Token: 0x0400007E RID: 126
protected int initradius;
// Token: 0x0400007F RID: 127
protected static readonly int radiusdec = 30;
// Token: 0x04000080 RID: 128
protected static readonly int alphabiasshift = 10;
// Token: 0x04000081 RID: 129
protected static readonly int initalpha = 1 << NeuQuant.alphabiasshift;
// Token: 0x04000082 RID: 130
protected int alphadec;
// Token: 0x04000083 RID: 131
protected static readonly int radbiasshift = 8;
// Token: 0x04000084 RID: 132
protected static readonly int radbias = 1 << NeuQuant.radbiasshift;
// Token: 0x04000085 RID: 133
protected static readonly int alpharadbshift = NeuQuant.alphabiasshift + NeuQuant.radbiasshift;
// Token: 0x04000086 RID: 134
protected static readonly int alpharadbias = 1 << NeuQuant.alpharadbshift;
// Token: 0x04000087 RID: 135
protected byte[] thepicture;
// Token: 0x04000088 RID: 136
protected int lengthcount;
// Token: 0x04000089 RID: 137
protected int samplefac;
// Token: 0x0400008A RID: 138
protected int[][] network;
// Token: 0x0400008B RID: 139
protected int[] netindex = new int[256];
// Token: 0x0400008C RID: 140
protected int[] bias;
// Token: 0x0400008D RID: 141
protected int[] freq;
// Token: 0x0400008E RID: 142
protected int[] radpower;
}
}
+16
View File
@@ -0,0 +1,16 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("0.0.0.1")]
[assembly: AssemblyTitle("Gif Animate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
+20
View File
@@ -0,0 +1,20 @@
using System;
namespace Gif.Components
{
// Token: 0x02000004 RID: 4
public struct Rectangle
{
// Token: 0x0400001F RID: 31
public int xmin;
// Token: 0x04000020 RID: 32
public int ymin;
// Token: 0x04000021 RID: 33
public int xmax;
// Token: 0x04000022 RID: 34
public int ymax;
}
}
+21
View File
@@ -0,0 +1,21 @@
using System;
namespace Gif.Components
{
// Token: 0x02000005 RID: 5
public struct Size
{
// Token: 0x06000021 RID: 33 RVA: 0x00002C9A File Offset: 0x0000109A
public Size(int width, int height)
{
this.width = width;
this.height = height;
}
// Token: 0x04000023 RID: 35
public int width;
// Token: 0x04000024 RID: 36
public int height;
}
}