diff --git a/pngchunk/pngchunk.vb b/pngchunk/pngchunk.vb index 114fe76..38f00bb 100755 --- a/pngchunk/pngchunk.vb +++ b/pngchunk/pngchunk.vb @@ -153,7 +153,7 @@ End While End Sub - Private Function BigEndianUInt32(ByRef buf As Byte(), Optional offset As Integer = 0) As UInt32 + Private Function BigEndianUInt32(ByRef buf As Byte(), Optional offset As Integer = 0) As UInteger Return &H1000000L * buf(0 + offset) + &H10000L * buf(1 + offset) + &H100L * buf(2 + offset) + buf(3 + offset) End Function @@ -262,13 +262,31 @@ End If Case "tEXt" - Dim keywordlength As Integer = Array.FindIndex(data, Function(x) x = &H0) - 1 + Dim keywordlength As Integer = Array.FindIndex(data, Function(x) x = &H0) Dim keyword(keywordlength - 1) As Byte Dim textstring(data.Length - keywordlength - 1 - 1) As Byte Array.Copy(data, 0, keyword, 0, keywordlength) Array.Copy(data, keywordlength + 1, textstring, 0, data.Length - keywordlength - 1) Console.WriteLine("keyword: {0}", System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(keyword)) Console.WriteLine("value: {0}", System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(textstring)) + + Case "iCCP" + Dim namelength As Integer = Array.FindIndex(data, Function(x) x = &H0) + Dim profilename(namelength - 1) As Byte + Array.Copy(data, 0, profilename, 0, namelength) + Console.WriteLine("profile name: {0}", System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(profilename)) + + Case "cHRM" + Dim offset As Integer = 0 + For Each pointname As String In {"white point", "red", "green ", "blue"} + Dim xcounts, ycounts As UInteger + xcounts = BigEndianUInt32(data, offset) + ycounts = BigEndianUInt32(data, offset + 4) + + Console.WriteLine("{0}: x = {1:g} y = {2:g}", pointname, xcounts / 100000.0, ycounts / 100000.0) + + offset += 8 + Next End Select End Sub