private static void SetCommentExtension(byte[] gifBytes, ref int byteIndex, ref GifData gifData) { CommentExtension commentEx = new CommentExtension(); // Extension Introducer(1 Byte) // 0x21 commentEx.m_extensionIntroducer = gifBytes[byteIndex]; byteIndex++; // Comment Label(1 Byte) // 0xfe commentEx.m_commentLabel = gifBytes[byteIndex]; byteIndex++; // Block Size & Comment Data List while (true) { // Block Size(1 Byte) byte blockSize = gifBytes[byteIndex]; byteIndex++; if (blockSize == 0x00) { // Block Terminator(1 Byte) break; } var commentDataBlock = new CommentExtension.CommentDataBlock(); commentDataBlock.m_blockSize = blockSize; // Comment Data(n Byte) commentDataBlock.m_commentData = new byte[commentDataBlock.m_blockSize]; for (int i = 0; i < commentDataBlock.m_commentData.Length; i++) { commentDataBlock.m_commentData[i] = gifBytes[byteIndex]; byteIndex++; } if (commentEx.m_commentDataList == null) { commentEx.m_commentDataList = new List <CommentExtension.CommentDataBlock>(); } commentEx.m_commentDataList.Add(commentDataBlock); } if (gifData.m_commentExList == null) { gifData.m_commentExList = new List <CommentExtension>(); } gifData.m_commentExList.Add(commentEx); }
static void SetCommentExtension (byte[] gifBytes, ref int byteIndex, ref GifData gifData) { CommentExtension commentEx = new CommentExtension (); // Extension Introducer(1 Byte) // 0x21 commentEx.extensionIntroducer = gifBytes[byteIndex]; byteIndex++; // Comment Label(1 Byte) // 0xfe commentEx.commentLabel = gifBytes[byteIndex]; byteIndex++; // Block Size & Comment Data List while (true) { // Block Size(1 Byte) byte blockSize = gifBytes[byteIndex]; byteIndex++; if (blockSize == 0x00) { // Block Terminator(1 Byte) break; } var commentDataBlock = new CommentExtension.CommentDataBlock (); commentDataBlock.blockSize = blockSize; // Comment Data(n Byte) commentDataBlock.commentData = new byte[commentDataBlock.blockSize]; for (int i = 0; i < commentDataBlock.commentData.Length; i++) { commentDataBlock.commentData[i] = gifBytes[byteIndex]; byteIndex++; } if (commentEx.commentDataList == null) { commentEx.commentDataList = new List<CommentExtension.CommentDataBlock> (); } commentEx.commentDataList.Add (commentDataBlock); } if (gifData.commentExList == null) { gifData.commentExList = new List<CommentExtension> (); } gifData.commentExList.Add (commentEx); }