aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.AnimatedGif/Decoding/GifImageDescriptor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.AnimatedGif/Decoding/GifImageDescriptor.cs')
-rw-r--r--Software/Visual_Studio/Tango.AnimatedGif/Decoding/GifImageDescriptor.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.AnimatedGif/Decoding/GifImageDescriptor.cs b/Software/Visual_Studio/Tango.AnimatedGif/Decoding/GifImageDescriptor.cs
new file mode 100644
index 000000000..ad344ef4e
--- /dev/null
+++ b/Software/Visual_Studio/Tango.AnimatedGif/Decoding/GifImageDescriptor.cs
@@ -0,0 +1,43 @@
+using System;
+using System.IO;
+
+namespace Tango.AnimatedGif.Decoding
+{
+ internal class GifImageDescriptor
+ {
+ public int Left { get; private set; }
+ public int Top { get; private set; }
+ public int Width { get; private set; }
+ public int Height { get; private set; }
+ public bool HasLocalColorTable { get; private set; }
+ public bool Interlace { get; private set; }
+ public bool IsLocalColorTableSorted { get; private set; }
+ public int LocalColorTableSize { get; private set; }
+
+ private GifImageDescriptor()
+ {
+ }
+
+ internal static GifImageDescriptor ReadImageDescriptor(Stream stream)
+ {
+ var descriptor = new GifImageDescriptor();
+ descriptor.Read(stream);
+ return descriptor;
+ }
+
+ private void Read(Stream stream)
+ {
+ byte[] bytes = new byte[9];
+ stream.ReadAll(bytes, 0, bytes.Length);
+ Left = BitConverter.ToUInt16(bytes, 0);
+ Top = BitConverter.ToUInt16(bytes, 2);
+ Width = BitConverter.ToUInt16(bytes, 4);
+ Height = BitConverter.ToUInt16(bytes, 6);
+ byte packedFields = bytes[8];
+ HasLocalColorTable = (packedFields & 0x80) != 0;
+ Interlace = (packedFields & 0x40) != 0;
+ IsLocalColorTableSorted = (packedFields & 0x20) != 0;
+ LocalColorTableSize = 1 << ((packedFields & 0x07) + 1);
+ }
+ }
+}