Exemplo n.º 1
0
		public byte [] GetBytes (bool is_little)
		{
			bool ascii = true;
			string description = Value;
			System.Text.Encoding enc;
			string heading;

			for (int i = 0; i < description.Length; i++) {
				if (description [i] > 127) {
					ascii = false;
					break;
				}
			}

			if (ascii) {
				heading = "ASCII\0\0\0";
				enc = new System.Text.ASCIIEncoding ();
			} else {
				heading = "Unicode\0";
				enc = new System.Text.UnicodeEncoding (! is_little, true);
			}
			
			int len = enc.GetByteCount (description);
			byte [] data = new byte [len + heading.Length];
			System.Text.Encoding.ASCII.GetBytes (heading, 0, heading.Length, data, 0);
			enc.GetBytes (Value, 0, Value.Length, data, heading.Length);
			
			UserComment c = new UserComment (data, is_little);
			System.Console.WriteLine ("old = \"{0}\" new = \"{1}\" heading = \"{2}\"", c.Value, description, heading);
			return data;
		}
Exemplo n.º 2
0
		public void SetDescription (string value)
		{
			Exif.ExifContent exif_content = this.ExifData.GetContents (Exif.Ifd.Exif);			
			Exif.ExifEntry entry = exif_content.GetEntry (Exif.Tag.UserComment);

			UserComment comment = new UserComment (value);
			byte [] data = comment.GetBytes (entry.ByteOrder == Exif.ByteOrder.Intel);
			entry.SetData (data);
		}