Imagen Gdi

Embed Size (px)

Citation preview

  • 7/28/2019 Imagen Gdi

    1/2

    If you have ever worked with mechanical andengineering drawing or digital images, you are probably aware

    of metadata. Metadata is information about the image, that's not part of the image itself. When an engineer

    draws an image, metadata is often added, such as the following information: last updated, updated

    by,data , place, and names. A photograph might include metadata such as image title, manufacturer, and

    model.

    In the .NET Framework library, the PropertyItem object is used as a placeholder for metadata. ThePropertyItem class provides four properties: Id, Len, Type, and Value. All of these properties have both read

    and write access.

    The Id property is a tag, which identifies the metadata item. Table 9.10 describes Id tag values.

    The Value property is an array of values whose format is determined by the Type property. The Len property

    represents the length of the array of values in bytes. The Type property represents the data type of values

    stored in the array. Table 9.11 described the format of the Type property values.

    TABLE 9.10: Id values

    Hexadecimal

    Value Description0x0320 Image title0x010F Equipment

    manufacturer0x0110 Equipment

    model0x9003 ExifDTOriginal0x829A EXIF exposure

    time0x5090 Luminance

    table0x5091 Chrominance

    tableTABLE 9.11: Format of Type property values

    Numeric Value Description1 A Byte object2 An array of Byte object encoded as ASCII3 A 16-bit integer4 A 32-bit integer5 An array of two Byte objects that represent a rational number6 Not used7

    Undefined

    8 Not used9 Slong10 SrationalAn Image object may contain more than one PropertyItem object. The PropertyItems property of the Image class

    represents an array of PropertyItem objects corresponding to an image. The PropertyIdList property of the Image class

    returns an array of property IDs stored in an image object. Listing 9.17 uses the PropertyItems property of the Image

    class and reads all property items of an image.

    http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/http://www.c-sharpcorner.com/UploadFile/puranindia/751/
  • 7/28/2019 Imagen Gdi

    2/2

    LISTING 9.17: Reading the metadata of a bitmap

    PrivateSub Form1_Load(ByVal sender AsObject,ByVal e As System.EventArgs)

    ' Create an image from a file

    Dim gAs Graphics = Me.CreateGraphics()

    Dim curImageAs Image = Image.FromFile("C:/Documents and Settings/Manu/Desktop/16864z.Bmp")

    Dim rect AsNew Rectangle(20, 20, 100, 100)g.DrawImage(curImage, rect)

    ' Create an array of PropertyItem objects and read items using PropertyItems

    Dim propItemsAs PropertyItem() = curImage.PropertyItems' Create values of PropertyItem members

    ForEach propItem As PropertyItem In propItems

    Dim encoderAsNew System.Text.ASCIIEncoding()

    Dim str AsString ="ID =" + propItem.Id.ToString("x")

    str += ", Type =" + propItem.Type.ToString()

    str += ", Length =" + propItem.Len.ToString()str += ", Value =" + encoder.GetString(propItem.Value)

    MessageBox.Show(str)

    Next' Dispose of object

    g.Dispose()

    EndSub

    Figure 9.25 shows the output from Listing 9.17.

    FIGURE 9.25: Reading the metadata of a bitmap