private static void SetPlainTextExtension(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { PlainTextExtension plainTxtEx = new PlainTextExtension(); // Extension Introducer(1 Byte) // 0x21 plainTxtEx.m_extensionIntroducer = gifBytes[byteIndex]; byteIndex++; // Plain Text Label(1 Byte) // 0x01 plainTxtEx.m_plainTextLabel = gifBytes[byteIndex]; byteIndex++; // Block Size(1 Byte) // 0x0c plainTxtEx.m_blockSize = gifBytes[byteIndex]; byteIndex++; // Text Grid Left Position(2 Bytes) // Not supported byteIndex += 2; // Text Grid Top Position(2 Bytes) // Not supported byteIndex += 2; // Text Grid Width(2 Bytes) // Not supported byteIndex += 2; // Text Grid Height(2 Bytes) // Not supported byteIndex += 2; // Character Cell Width(1 Bytes) // Not supported byteIndex++; // Character Cell Height(1 Bytes) // Not supported byteIndex++; // Text Foreground Color Index(1 Bytes) // Not supported byteIndex++; // Text Background Color Index(1 Bytes) // Not supported byteIndex++; // Block Size & Plain Text Data List while (true) { // Block Size(1 Byte) byte blockSize = gifBytes[byteIndex]; byteIndex++; if (blockSize == 0x00) { // Block Terminator(1 Byte) break; } var plainTextDataBlock = new PlainTextExtension.PlainTextDataBlock(); plainTextDataBlock.m_blockSize = blockSize; // Plain Text Data(n Byte) plainTextDataBlock.m_plainTextData = new byte[plainTextDataBlock.m_blockSize]; for (int i = 0; i < plainTextDataBlock.m_plainTextData.Length; i++) { plainTextDataBlock.m_plainTextData[i] = gifBytes[byteIndex]; byteIndex++; } if (plainTxtEx.m_plainTextDataList == null) { plainTxtEx.m_plainTextDataList = new List <PlainTextExtension.PlainTextDataBlock>(); } plainTxtEx.m_plainTextDataList.Add(plainTextDataBlock); } if (gifData.m_plainTextExList == null) { gifData.m_plainTextExList = new List <PlainTextExtension>(); } gifData.m_plainTextExList.Add(plainTxtEx); }
static void SetPlainTextExtension (byte[] gifBytes, ref int byteIndex, ref GifData gifData) { PlainTextExtension plainTxtEx = new PlainTextExtension (); // Extension Introducer(1 Byte) // 0x21 plainTxtEx.extensionIntroducer = gifBytes[byteIndex]; byteIndex++; // Plain Text Label(1 Byte) // 0x01 plainTxtEx.plainTextLabel = gifBytes[byteIndex]; byteIndex++; // Block Size(1 Byte) // 0x0c plainTxtEx.blockSize = gifBytes[byteIndex]; byteIndex++; // Text Grid Left Position(2 Bytes) // Not supported byteIndex += 2; // Text Grid Top Position(2 Bytes) // Not supported byteIndex += 2; // Text Grid Width(2 Bytes) // Not supported byteIndex += 2; // Text Grid Height(2 Bytes) // Not supported byteIndex += 2; // Character Cell Width(1 Bytes) // Not supported byteIndex++; // Character Cell Height(1 Bytes) // Not supported byteIndex++; // Text Foreground Color Index(1 Bytes) // Not supported byteIndex++; // Text Background Color Index(1 Bytes) // Not supported byteIndex++; // Block Size & Plain Text Data List while (true) { // Block Size(1 Byte) byte blockSize = gifBytes[byteIndex]; byteIndex++; if (blockSize == 0x00) { // Block Terminator(1 Byte) break; } var plainTextDataBlock = new PlainTextExtension.PlainTextDataBlock (); plainTextDataBlock.blockSize = blockSize; // Plain Text Data(n Byte) plainTextDataBlock.plainTextData = new byte[plainTextDataBlock.blockSize]; for (int i = 0; i < plainTextDataBlock.plainTextData.Length; i++) { plainTextDataBlock.plainTextData[i] = gifBytes[byteIndex]; byteIndex++; } if (plainTxtEx.plainTextDataList == null) { plainTxtEx.plainTextDataList = new List<PlainTextExtension.PlainTextDataBlock> (); } plainTxtEx.plainTextDataList.Add (plainTextDataBlock); } if (gifData.plainTextExList == null) { gifData.plainTextExList = new List<PlainTextExtension> (); } gifData.plainTextExList.Add (plainTxtEx); }