public void ImageMetadata()
        {
            ImageMetadata        metadata;
            List <MetadataModel> modelList;
            MetadataTag          tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS);

            tag.Key   = "KEY";
            tag.ID    = 11;
            tag.Value = new double[] { 0d, 41d, -523d, -0.41d };

            dib = FreeImage.Allocate(1, 1, 1, 1, 0, 0);
            Assert.IsFalse(dib.IsNull);

            metadata = new ImageMetadata(dib, true);
            Assert.AreEqual(0, metadata.Count);
            Assert.IsTrue(metadata.HideEmptyModels);
            Assert.IsEmpty(metadata.List);

            metadata = new ImageMetadata(dib, false);
            Assert.AreEqual(FreeImage.FREE_IMAGE_MDMODELS.Length, metadata.Count);
            Assert.IsFalse(metadata.HideEmptyModels);
            Assert.IsNotEmpty(metadata.List);

            metadata.HideEmptyModels = true;
            metadata.AddTag(tag);

            Assert.AreEqual(1, metadata.Count);
            Assert.IsNotEmpty(metadata.List);

            modelList = metadata.List;
            Assert.AreEqual(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, modelList[0].Model);

            System.Collections.IEnumerator enumerator = metadata.GetEnumerator();
            Assert.IsTrue(enumerator.MoveNext());
            Assert.IsNotNull((MetadataModel)enumerator.Current);
            Assert.IsFalse(enumerator.MoveNext());

            FreeImage.UnloadEx(ref dib);
        }
Ejemplo n.º 2
0
        public void ImageMetadata()
        {
            ImageMetadata metadata;
            List<MetadataModel> modelList;
            MetadataTag tag = new MetadataTag(FREE_IMAGE_MDMODEL.FIMD_COMMENTS);
            tag.Key = "KEY";
            tag.ID = 11;
            tag.Value = new double[] { 0d, 41d, -523d, -0.41d };

            dib = FreeImage.Allocate(1, 1, 1, 1, 0, 0);
            Assert.IsFalse(dib.IsNull);

            metadata = new ImageMetadata(dib, true);
            Assert.AreEqual(0, metadata.Count);
            Assert.IsTrue(metadata.HideEmptyModels);
            Assert.IsEmpty(metadata.List);

            metadata = new ImageMetadata(dib, false);
            Assert.AreEqual(FreeImage.FREE_IMAGE_MDMODELS.Length, metadata.Count);
            Assert.IsFalse(metadata.HideEmptyModels);
            Assert.IsNotEmpty(metadata.List);

            metadata.HideEmptyModels = true;
            metadata.AddTag(tag);

            Assert.AreEqual(1, metadata.Count);
            Assert.IsNotEmpty(metadata.List);

            modelList = metadata.List;
            Assert.AreEqual(FREE_IMAGE_MDMODEL.FIMD_COMMENTS, modelList[0].Model);

            System.Collections.IEnumerator enumerator = metadata.GetEnumerator();
            Assert.IsTrue(enumerator.MoveNext());
            Assert.IsNotNull((MetadataModel)enumerator.Current);
            Assert.IsFalse(enumerator.MoveNext());

            FreeImage.UnloadEx(ref dib);
        }