View property items for an image
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
1 post
Page 1 of 1
To view various property items for an image, you can use the Image.PropertyItems to list every item available. One example could be
Code: Select all
There is a Value property for the PropertyItem structure, it is a byte array that contains the actual value. You can use the Type property together with the Value to get the actual value.
For Each Item As PropertyItem In MyImage.PropertyItems
MessageBox.Show(Item.Id & ": " & Item.Len & " bytes value.")
Next
Code: Select all
Then we can edit our first function to show the actual value too:
Private Function GetValue(prop As PropertyItem) As Object
Select Case prop.Type
Case 1
Return prop.Value(0)
Case 2
Return System.Text.Encoding.ASCII.GetString(prop.Value)
Case 3
Return BitConverter.ToUInt16(prop.Value, 0)
Case 4
Return BitConverter.ToUInt32(prop.Value, 0)
Case 5
Return New UInteger() {BitConverter.ToUInt32(prop.Value, 0), BitConverter.ToUInt32(prop.Value, 4)} 'URational class is not supported by .NET'
Case 6
Return CSByte(prop.Value(0))
Case 7
Return prop.Value(0) 'Undefined'
Case 8
Return BitConverter.ToInt16(prop.Value, 0)
Case 9
Return BitConverter.ToInt32(prop.Value, 0)
Case 10
Return New Integer() {BitConverter.ToInt32(prop.Value, 0), BitConverter.ToInt32(prop.Value, 4)} 'Rational class is not supported by .NET'
Case 11
Return BitConverter.ToSingle(prop.Value, 0)
Case 12
Return BitConverter.ToDouble(prop.Value, 0)
End Select
Return prop.Value
End Function
Code: Select all
For Each Item As PropertyItem In MyImage.PropertyItems
MessageBox.Show(Item.Id & ": " & GetValue(Item).ToString())
Next
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023