Render() public method

Renders the current instance to a ByteVector.
public Render ( ) : ByteVector
return ByteVector
        /// <summary>
        ///    Render the whole file and write it back.
        /// </summary>
        private void WriteFile()
        {
            // Check, if IFD0 is contained
            IFDTag exif = ImageTag.Exif;
            if (exif == null)
                throw new Exception ("Tiff file without tags");

            UpdateTags (exif);

            // first IFD starts at 8
            uint first_ifd_offset = 8;
            ByteVector data = RenderHeader (first_ifd_offset);

            var renderer = new IFDRenderer (IsBigEndian, exif.Structure, first_ifd_offset);

            data.Add (renderer.Render ());

            Insert (data, 0, Length);
        }
Beispiel #2
0
		/// <summary>
		///    Render the whole file and write it back.
		/// </summary>
		private void WriteFile ()
		{
			// Check, if IFD0 is contained
			IFDTag exif = ImageTag.Exif;
			if (exif == null)
				throw new Exception ("Tiff file without tags");
			
			UpdateTags (exif);
			
			// first IFD starts at 8
			uint first_ifd_offset = 8;
			
			ByteVector data = new ByteVector ();
			
			if (is_bigendian)
				data.Add ("MM");
			else
				data.Add ("II");
			
			data.Add (ByteVector.FromUShort (42, is_bigendian));
			data.Add (ByteVector.FromUInt (first_ifd_offset, is_bigendian));
			
			var renderer = new IFDRenderer (is_bigendian, exif.Structure, first_ifd_offset);
			
			data.Add (renderer.Render ());
			
			Insert (data, 0, Length);
		}
Beispiel #3
0
		/// <summary>
		///    Creates a <see cref="ByteVector"/> for the Exif segment of this file
		/// </summary>
		/// <returns>
		///    A <see cref="ByteVector"/> with the whole Exif segment, if exif tags
		///    exists, otherwise null.
		/// </returns>
		private ByteVector RenderExifSegment ()
		{
			// 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;
		}