'Create an Image object.
Dim image As Bitmap = New Bitmap("c:\FakePhoto.jpg")
'Get the PropertyItems property from image.
Dim propItems As PropertyItem() = image.PropertyItems
'Set up the display.
Dim font As New Font("Arial", 12)
Dim blackBrush As New SolidBrush(Color.Black)
Dim X As Integer = 0
Dim Y As Integer = 0
'For each PropertyItem in the array, display the ID, type, and length.
Dim count As Integer = 0
Dim propItem As PropertyItem
For Each propItem In propItems
e.Graphics.DrawString( _
"Property Item " & count.ToString(), _
font, _
blackBrush, _
X, Y)
Y += font.Height
e.Graphics.DrawString( _
" iD: 0x" & propItem.Id.ToString("x"), _
font, _
blackBrush, _
X, Y)
Y += font.Height
e.Graphics.DrawString( _
" type: " & propItem.Type.ToString(), _
font, _
blackBrush, _
X, Y)
Y += font.Height
e.Graphics.DrawString( _
" length: " & propItem.Len.ToString() & " bytes", _
font, _
blackBrush, _
X, Y)
Y += font.Height
count += 1
Next propItem
'Convert the value of the second property to a string, and display it.
Dim encoding As New System.Text.ASCIIEncoding()
Dim manufacturer As String = encoding.GetString(propItems(1).Value)
e.Graphics.DrawString( _
"The equipment make is " & manufacturer & ".", _
font, _
blackBrush, _
X, Y)
// Create an Image object.
Image image = new Bitmap(@"c:\FakePhoto.jpg");
// Get the PropertyItems property from image.
PropertyItem[] propItems = image.PropertyItems;
// Set up the display.
Font font = new Font("Arial", 12);
SolidBrush blackBrush = new SolidBrush(Color.Black);
int X = 0;
int Y = 0;
// For each PropertyItem in the array, display the ID, type, and
// length.
int count = 0;
foreach (PropertyItem propItem in propItems)
{
e.Graphics.DrawString(
"Property Item " + count.ToString(),
font,
blackBrush,
X, Y);
Y += font.Height;
e.Graphics.DrawString(
" iD: 0x" + propItem.Id.ToString("x"),
font,
blackBrush,
X, Y);
Y += font.Height;
e.Graphics.DrawString(
" type: " + propItem.Type.ToString(),
font,
blackBrush,
X, Y);
Y += font.Height;
e.Graphics.DrawString(
" length: " + propItem.Len.ToString() + " bytes",
font,
blackBrush,
X, Y);
Y += font.Height;
count++;
}
// Convert the value of the second property to a string, and display
// it.
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
string manufacturer = encoding.GetString(propItems[1].Value);
e.Graphics.DrawString(
"The equipment make is " + manufacturer + ".",
font,
blackBrush,
X, Y);