Imports System.Drawing.Imaging Imports System.Text Public Class Form1 Enum PropertyID PropertyTagDateTime = 306 PropertyTagExifDTOrig = 36867 PropertyTagEquipMake = 271 PropertyTagEquipModel = 272 End Enum Private Sub BtnLoad_Click(sender As Object, e As EventArgs) Handles BtnLoad.Click txtImageInfo.Clear() ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) ofd.Filter = "JPEGS|*.jpg|GIFs|*.gif|PNGs|*.png|TIF|*.tif" If ofd.ShowDialog() <> DialogResult.Cancel Then pbImage.Load(ofd.FileName) Dim img As Image = Image.FromFile(ofd.FileName) Dim imageType As String = "" If ImageFormat.Jpeg.Equals(img.RawFormat) Then imageType = "JPEG Image" GetPropItems(img, "Date and Time Taken: ", PropertyID.PropertyTagDateTime) GetPropItems(img, Environment.NewLine & "Camera Maker: ", PropertyID.PropertyTagEquipMake) GetPropItems(img, Environment.NewLine & "Camera Model: ", PropertyID.PropertyTagEquipModel) ElseIf ImageFormat.Gif.Equals(img.RawFormat) Then imageType = "GIF Image" ElseIf ImageFormat.Tiff.Equals(img.RawFormat) Then imageType = "Tiff Image" ElseIf ImageFormat.Png.Equals(img.RawFormat) Then imageType = "PNG Image" End If Dim imageWidth As String = img.Width.ToString() Dim imageHeight As String = img.Height.ToString() Dim imageResolution As String = img.HorizontalResolution.ToString() & "dpi" Dim imagePixelDepth As String = Image.GetPixelFormatSize(img.PixelFormat).ToString() txtImageInfo.Text &= vbNewLine & imageType & vbNewLine txtImageInfo.Text &= "Width = " & imageWidth & vbNewLine txtImageInfo.Text &= "Height = " & imageHeight & vbNewLine txtImageInfo.Text &= "Resolution = " & imageResolution & vbNewLine txtImageInfo.Text &= "Pixel Depth = " & imagePixelDepth & vbNewLine '======================================================= ' COLORS USED '======================================================= Dim colorPaletteLength As Integer = img.Palette.Entries.Length Dim colorsArray(colorPaletteLength) As String If img.Palette IsNot Nothing And (colorPaletteLength > 0 And colorPaletteLength < 257) Then For i = 0 To colorPaletteLength - 1 colorsArray(i) = ColorTranslator.ToHtml(img.Palette.Entries(i)) Next Dim removeDuplicateColors As New List(Of String)() For Each item In colorsArray If removeDuplicateColors.Contains(item) = False Then removeDuplicateColors.Add(item) End If Next Dim hexCount As Integer = 0 For Each hexVal In removeDuplicateColors ColorLabel("color" + hexCount.ToString(), hexVal) hexCount += 1 Next End If End If End Sub Private Sub ColorLabel(labelName As String, labelColor As String) Dim findLabel As Object = Controls.Find(labelName, False).FirstOrDefault() If findLabel IsNot Nothing Then findLabel.BackColor = ColorTranslator.FromHtml(labelColor) End If End Sub Private Sub GetPropItems(img As Image, message As String, ID As Integer) Try Dim propItem As PropertyItem = img.GetPropertyItem(ID) If propItem IsNot Nothing Then Dim encod As ASCIIEncoding = New ASCIIEncoding() Dim asciiInfo As String = encod.GetString(propItem.Value, 0, propItem.Len) txtImageInfo.Text &= message & asciiInfo End If Catch ex As Exception txtImageInfo.Text &= message & "Not Available" End Try End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim offsetX As Integer = 0 Dim offsetY As Integer = 0 Dim labelWidth As Integer = 30 Dim labelHeight As Integer = 30 For i = 0 To 255 If offsetX > 700 Then offsetX = 0 offsetY += labelHeight End If Dim labelNew As New Label With { .Name = "color" + (i).ToString(), .Size = New Size(labelWidth, labelHeight), .Location = New Point(labelWidth + offsetX, 400 + offsetY), .BackColor = SystemColors.ControlDark, .Text = (i).ToString() } Controls.Add(labelNew) offsetX += 30 Next End Sub End Class