This documentation is for the old version. Go to the latest Graphics Mill docs

AdobeResourceDictionary Class

This class represents a dictionary of Adobe® image resource blocks, each block is represented by the AdobeResourceBlock class.

Namespace: Aurigma.GraphicsMill.Codecs
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public Class AdobeResourceDictionary _
	Inherits MetadataDictionary
C#
public class AdobeResourceDictionary : MetadataDictionary

Remarks

Adobe® applications (first of all Adobe® Photoshop®) store meta-information in so called Adobe® image resource blocks. Graphics Mill for .NET provides AdobeResourceDictionary class to facilitate work with these data.

All functionality of this class is implemented in base class MetadataDictionary. To put or get some Adobe® image resource block, you should use the Item[Object] property. Just pass ID of the Adobe® image resource block as an argument into this property. Refer Adobe® Photoshop® File Formats Specification for exact Adobe® image resource block ID values.

Instances of AdobeResourceDictionary class are used in two interfaces:

  • IMetadataReadSupport - objects which implement this interface can read resource blocks from a file and retrieve them as instance of AdobeResourceDictionary class.
  • IMetadataWriteSupport - objects which implement this intereface can accept instances of AdobeResourceDictionary class and encode contained resource blocks to a file. No validation of the internal structure of the binary data is performed during encoding so user is responsible for providing correctly filled AdobeResourceDictionary class instance. Files which have been saved with incorrect Adobe® image resource blocks can produce errors during opening or processing in Adobe® applications.

Examples

The code sample below demonstrates how to remove thumbnail from Adobe® image resource blocks and mark the image as copyrighted. Thumbnail block ID is 0x0409 and copyright flag ID is 0x040A.

Visual Basic
Dim srcFileName As String = "c:/mountain.jpg"
Dim dstFileName As String = "c:/mountain2.jpg"

' Open reader on the file you need to modify metadata for   
Dim reader As New Aurigma.GraphicsMill.Codecs.JpegReader(srcFileName)
Dim adobeResources As Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary = reader.AdobeResources
If adobeResources Is Nothing Then
    adobeResources = New Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary
End If

' Create new adobe image resource block with the required metadata
Dim arBlock As New Aurigma.GraphicsMill.Codecs.AdobeResourceBlock("Copyright", New Byte() {1})
' Set this block to the item with 0x040A ID (copyright flag)
adobeResources.Item(&H40A) = arBlock
' Remove a block with 0x0409 (thumbnail data)
adobeResources.Remove(&H409)

' Write new bitmap and metadata
Dim writer As New Aurigma.GraphicsMill.Codecs.JpegWriter()
writer.Open(dstFileName)
writer.AdobeResources = adobeResources
writer.AddFrame(reader.LoadFrame(0))
writer.Close()

reader.Close()
C#
string srcFileName = @"c:/mountain.jpg";
string dstFileName = @"c:/mountain2.jpg";

using (Aurigma.GraphicsMill.Codecs.JpegReader reader = new Aurigma.GraphicsMill.Codecs.JpegReader())
{
    // Open reader on the file you need to modify metadata for  
    reader.Open(srcFileName);
    Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary adobeResources = reader.AdobeResources;
    if (adobeResources == null)
    {
        adobeResources = new Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary();
    }
    
    // Create new adobe image resource block with the required metadata
    Aurigma.GraphicsMill.Codecs.AdobeResourceBlock arBlock = new
        Aurigma.GraphicsMill.Codecs.AdobeResourceBlock("Copyright", new byte[] { 1 });
    // Set this block to the item with 0x040A ID (copyright flag)
    adobeResources[0x040A] = arBlock;
    // Remove a block with 0x0409 (thumbnail data)
    adobeResources.Remove(0x0409);

    // Write new bitmap and metadata
    using (Aurigma.GraphicsMill.Codecs.JpegWriter writer = new Aurigma.GraphicsMill.Codecs.JpegWriter())
    {
        writer.Open(dstFileName);
        writer.AdobeResources = adobeResources;
        writer.AddFrame(reader.LoadFrame(0));
    }
}

Inheritance Hierarchy

See Also

Reference