Exemplo n.º 1
0
        public void Select(SemWeb.StatementSink sink)
        {
            byte []        data   = null;
            ImageDirectory props  = Root.ReadDirectory(Tag.ImageProps);
            ImageDirectory camera = props.ReadDirectory(Tag.CameraObject);

            data = props.ReadEntry(Tag.TimeStamp);
            if (data != null)
            {
                MetadataStore.AddLiteral(sink, "xmp:CreateDate", new CaptureTime(data, little).ToString());
            }

            data = props.ReadEntry(Tag.ImageSpec);
            if (data != null)
            {
                ImageSpec spec = new ImageSpec(data, little);
                MetadataStore.AddLiteral(sink, "tiff:Orientation", ((int)spec.Orientation).ToString());
                MetadataStore.AddLiteral(sink, "tiff:ImageWidth", spec.ImageWidth.ToString());
                MetadataStore.AddLiteral(sink, "tiff:ImageLength", spec.ImageHeight.ToString());
                string comp = spec.ComponentBitDepth.ToString();

                if (spec.IsColor)
                {
                    MetadataStore.Add(sink, "tiff:BitsPerSample", "rdf:Seq", new string [] { comp, comp, comp });
                }
                else
                {
                    MetadataStore.Add(sink, "tiff:BitsPerSample", "rdf:Seq", new string [] { comp });
                }

                if (!spec.HasSquarePixels)
                {
                    MetadataStore.AddLiteral(sink, "tiff:XResolution",
                                             (1000000 * spec.PixelAspectRatio).ToString());
                    MetadataStore.AddLiteral(sink, "tiff:YResolution",
                                             (1000000 * (1 / spec.PixelAspectRatio)).ToString());
                }
            }

            data = camera.ReadEntry(Tag.CanonRawMakeModel);
            if (data != null)
            {
                string    make_model = System.Text.Encoding.ASCII.GetString(data, 0, data.Length - 1);
                string [] vals       = make_model.Split(new char [] { '\0' });
                MetadataStore.AddLiteral(sink, "tiff:Make", vals [0]);
                MetadataStore.AddLiteral(sink, "tiff:Model", vals [1]);
            }

            /*
             * // FIXME this doesn't appear to be ascii.
             * data = camera.ReadEntry (Tag.OwnerName);
             * if (data != null) {
             *      string name = System.Text.Encoding.ASCII.GetString (data, 0, data.Length - 1);
             *      MetadataStore.AddLiteral (sink, "dc:creator", "rdf:Seq", new SemWeb.Literal (name));
             * }
             */
        }
Exemplo n.º 2
0
 public ImageDirectory ReadDirectory(Tag tag)
 {
     foreach (Entry e in entry_list)
     {
         if (e.Tag == tag)
         {
             uint           subdir_start = this.start + e.Offset;
             ImageDirectory subdir       = new ImageDirectory(stream, subdir_start, subdir_start + e.Size, little);
             return(subdir);
         }
     }
     return(null);
 }
Exemplo n.º 3
0
        public override PixbufOrientation GetOrientation()
        {
            PixbufOrientation orientation = PixbufOrientation.TopLeft;
            ImageDirectory    props       = Root.ReadDirectory(Tag.ImageProps);

            byte [] data = props.ReadEntry(Tag.ImageSpec);

            if (data != null)
            {
                orientation = new ImageSpec(data, little).Orientation;
            }
            //else
            //System.Console.WriteLine ("NO ORIENTATION");

            return(orientation);
        }
Exemplo n.º 4
0
        public void Dump()
        {
            Root.Dump();
            ImageDirectory props = Root.ReadDirectory(Tag.ImageProps);

            props.Dump();

            /*
             *       string path = "out2.jpg";
             * System.IO.File.Delete (path);
             *
             * System.IO.Stream output = System.IO.File.Open (path, System.IO.FileMode.OpenOrCreate);
             * byte [] data = GetEmbeddedThumbnail ();
             * System.Console.WriteLine ("data length {0}", data != null ? data.Length : -1);
             * output.Write (data, 0, data.Length);
             * output.Close ();
             */
        }
Exemplo n.º 5
0
		public ImageDirectory ReadDirectory (Tag tag)
		{
			foreach (Entry e in entry_list) {
				if (e.Tag == tag) {
					uint subdir_start = this.start + e.Offset;
					ImageDirectory subdir = new ImageDirectory (stream, subdir_start, subdir_start + e.Size, little);
					return subdir;
				}
			}
			return null;
		}