Logo Search packages:      
Sourcecode: f-spot version File versions  Download package

ByteVector TagLib::Jpeg::File::RenderExifSegment (  )  [inline, private]

Creates a ByteVector for the Exif segment of this file.

Returns:
A ByteVector with the whole Exif segment, if exif tags exists, otherwise null.

Definition at line 525 of file File.cs.

References TagLib::ByteVector::Add(), TagLib::ByteVector::Count, and TagLib::IFD::IFDTag::Structure.

            {
                  // Check, if IFD0 is contained
                  IFDTag exif = ImageTag.Exif;
                  if (exif == null)
                        return null;

                  // first IFD starts at 8
                  uint first_ifd_offset = 8;

                  // Render IFD0
                  // FIXME: store endianess and use it here
                  var renderer = new IFDRenderer (true, exif.Structure, first_ifd_offset);
                  ByteVector exif_data = renderer.Render ();

                  uint segment_size = (uint) (first_ifd_offset + exif_data.Count + 2 + 6);

                  // do not render data segments, which cannot fit into the possible segment size
                  if (segment_size > ushort.MaxValue)
                        throw new Exception ("Exif Segment is too big to render");

                  // Create whole segment
                  ByteVector data = new ByteVector (new byte [] { 0xFF, (byte) Marker.APP1 });
                  data.Add (ByteVector.FromUShort ((ushort) segment_size));
                  data.Add ("Exif\0\0");
                  data.Add (ByteVector.FromString ("MM", StringType.Latin1));
                  data.Add (ByteVector.FromUShort (42));
                  data.Add (ByteVector.FromUInt (first_ifd_offset));

                  // Add ifd data itself
                  data.Add (exif_data);

                  return data;
            }


Generated by  Doxygen 1.6.0   Back to index