public override void ParseFromRaw(ChunkRaw c) { if (c is null) { throw new System.ArgumentNullException(nameof(c)); } var nullsFound = 0; var nullsIdx = new int[3]; for (var k = 0; k < c.Data.Length; k++) { if (c.Data[k] != 0) { continue; } nullsIdx[nullsFound] = k; nullsFound++; if (nullsFound == 1) { k += 2; } if (nullsFound == 3) { break; } } if (nullsFound != 3) { throw new PngjException("Bad formed PngChunkITXT chunk"); } Key = ChunkHelper.ToString(c.Data, 0, nullsIdx[0]); var i = nullsIdx[0] + 1; compressed = c.Data[i] != 0; i++; if (compressed && c.Data[i] != 0) { throw new PngjException("Bad formed PngChunkITXT chunk - bad compression method "); } langTag = ChunkHelper.ToString(c.Data, i, nullsIdx[1] - i); translatedTag = ChunkHelper.ToStringUTF8(c.Data, nullsIdx[1] + 1, nullsIdx[2] - nullsIdx[1] - 1); i = nullsIdx[2] + 1; if (compressed) { var bytes = ChunkHelper.CompressBytes(c.Data, i, c.Data.Length - i, false); Val = ChunkHelper.ToStringUTF8(bytes); } else { Val = ChunkHelper.ToStringUTF8(c.Data, i, c.Data.Length - i); } }
public override void ParseFromRaw(ChunkRaw c) { int nullsFound = 0; int[] nullsIdx = new int[3]; for (int k = 0; k < c.Data.Length; k++) { if (c.Data[k] != 0) { continue; } nullsIdx[nullsFound] = k; nullsFound++; if (nullsFound == 1) { k += 2; } if (nullsFound == 3) { break; } } if (nullsFound != 3) { throw new PngjException("Bad formed PngChunkITXT chunk"); } key = ChunkHelper.ToString(c.Data, 0, nullsIdx[0]); int i = nullsIdx[0] + 1; compressed = c.Data[i] == 0 ? false : true; i++; if (compressed && c.Data[i] != 0) { throw new PngjException("Bad formed PngChunkITXT chunk - bad compression method "); } langTag = ChunkHelper.ToString(c.Data, i, nullsIdx[1] - i); translatedTag = ChunkHelper.ToStringUTF8(c.Data, nullsIdx[1] + 1, nullsIdx[2] - nullsIdx[1] - 1); i = nullsIdx[2] + 1; if (compressed) { byte[] bytes = ChunkHelper.compressBytes(c.Data, i, c.Data.Length - i, false); val = ChunkHelper.ToStringUTF8(bytes); } else { val = ChunkHelper.ToStringUTF8(c.Data, i, c.Data.Length - i); } }
public override void ParseFromRaw(ChunkRaw c) { int num = 0; int[] array = new int[3]; for (int i = 0; i < c.Data.Length; i++) { if (c.Data[i] == 0) { array[num] = i; num++; if (num == 1) { i += 2; } if (num == 3) { break; } } } if (num != 3) { throw new PngjException("Bad formed PngChunkITXT chunk"); } key = ChunkHelper.ToString(c.Data, 0, array[0]); int num2 = array[0] + 1; compressed = ((c.Data[num2] != 0) ? true : false); num2++; if (compressed && c.Data[num2] != 0) { throw new PngjException("Bad formed PngChunkITXT chunk - bad compression method "); } langTag = ChunkHelper.ToString(c.Data, num2, array[1] - num2); translatedTag = ChunkHelper.ToStringUTF8(c.Data, array[1] + 1, array[2] - array[1] - 1); num2 = array[2] + 1; if (compressed) { byte[] x = ChunkHelper.compressBytes(c.Data, num2, c.Data.Length - num2, compress: false); val = ChunkHelper.ToStringUTF8(x); } else { val = ChunkHelper.ToStringUTF8(c.Data, num2, c.Data.Length - num2); } }