Get Jpeg Information : Jpeg « 2D Graphics « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » 2D Graphics » Jpeg 
17.70.2.Get Jpeg Information
' Quote from
'Visual Basic 2005 Cookbook Solutions for VB 2005 Programmers
'by Tim Patrick (Author), John Craig (Author)
'# Publisher: O'Reilly Media, Inc. (September 212006)
'# Language: English
'# ISBN-100596101775
'# ISBN-13978-0596101770



Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

Public Class GetJpgInformation
    Public Shared Sub Main
        Console.WriteLine(ProcessJPEG.GetJpgInformation("yourfile.jpg"))
    End Sub
End Class


Public Class ProcessJPEG
    Public Shared Function GetJpgInformation(ByVal whichFile As StringAs String
        Dim bytesPropertyID As Byte()
        Dim stringPropertyID As String
        Dim loadedImage As System.Drawing.Bitmap
        Dim propertyIDs() As Integer
        Dim result As New System.Text.StringBuilder
        Dim counter As Integer
        Dim scanProperty As Integer

        loadedImage = New System.Drawing.Bitmap(whichFile)
        propertyIDs = loadedImage.PropertyIdList

        For Each scanProperty In propertyIDs
            bytesPropertyID = loadedImage.GetPropertyItem(scanProperty).Value
            stringPropertyID = System.Text.Encoding.ASCII.GetString(bytesPropertyID)

            For counter = To 255
                If counter < 32 Or counter > 127 Then
                    If (stringPropertyID.IndexOf(Chr(counter)) _
                          <> -1Then
                        stringPropertyID = Replace(stringPropertyID, _
                           Chr(counter)"")
                    End If
                End If
            Next counter

            ' ----- Display the property if it's reasonable.
            If (stringPropertyID.Length > 0And _
                  (stringPropertyID.Length < 70Then
                result.Append(scanProperty.ToString)
                result.Append(":   ")
                result.AppendLine(stringPropertyID)
            End If
        Next scanProperty

        ' ----- Display the results.
        Return result.ToString
    End Function

    Public Shared Function GetString_
      ByVal sourceBytes As Byte()) As String
        ' ----- Convert a byte array to a string, taking into
        '       account the terminating null character.
        Dim result As String

        result = System.Text.Encoding.ASCII.GetString(sourceBytes)
        If (result.EndsWith(vbNullChar= TrueThen _
           result = result.Substring(0, result.Length - 1)
        Return result
    End Function
End Class
17.70.Jpeg
17.70.1.Create Jpeg File
17.70.2.Get Jpeg Information
17.70.3.JPEG Compression
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.