Beispiel #1
0
        public void MD5Hash_Range()
        {
            string dir          = test_data_path;
            var    images_index = new Images.ImageIndex(dir);

            var test_index = dir + "images.idx";

            File.Delete(test_index);

            var test_image_name = dir + "lena.jpg";
            var test_image      = Image.FromFile(test_image_name, true);

            var files = images_index.ImageFilesIndexed();

            foreach (var file in files)
            {
                var image      = Image.FromFile(file, true);
                var similarity = Images.ImageMD5Hash.Compare(test_image, image);

                Console.WriteLine("{0} vs {1} similarity = {2}", test_image_name, file, similarity);
                Assert.IsTrue(similarity >= 0);
                Assert.IsTrue(similarity <= 100);
                image.Dispose();
            }
        }
        public void ImageUtils_GetFormat()
        {
            string dir          = test_data_path;
            var    images_index = new Images.ImageIndex(dir);

            var jpg    = dir + "lena.jpg";
            var format = CommonUtils.ImageUtils.GetImageFormat(jpg);

            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Jpeg);

            var bmp = dir + "koala1.bmp";

            format = CommonUtils.ImageUtils.GetImageFormat(bmp);
            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Bmp);

            var png = dir + "koala1.png";

            format = CommonUtils.ImageUtils.GetImageFormat(png);
            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Png);

            var gif = dir + "koala1.gif";

            format = CommonUtils.ImageUtils.GetImageFormat(gif);
            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Gif);

            var tiff = dir + "koala1.tif";

            format = CommonUtils.ImageUtils.GetImageFormat(tiff);
            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Tiff);
        }
 /// <summary>
 /// Initialize index data
 /// </summary>
 private void Initialize()
 {
     index_list = new List <Images.ImageIndex>();
     for (int i = 0; i < number_of_index; i++)
     {
         var index = new Images.ImageIndex();
         index.SetIndexName(String.Format("images{0}.idx", i));
         index_list.Add(index);
     }
 }
        public void ImageUtils_GetFormat_Image()
        {
            string dir          = test_data_path;
            var    images_index = new Images.ImageIndex(dir);

            var jpg    = dir + "lena.jpg";
            var img    = Image.FromFile(jpg, true);
            var format = CommonUtils.ImageUtils.GetImageFormat(img);

            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Jpeg);
            img.Dispose();

            var bmp = dir + "koala1.bmp";

            img    = Image.FromFile(bmp, true);
            format = CommonUtils.ImageUtils.GetImageFormat(img);
            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Bmp);
            img.Dispose();

            var png = dir + "koala1.png";

            img    = Image.FromFile(png, true);
            format = CommonUtils.ImageUtils.GetImageFormat(img);
            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Png);
            img.Dispose();

            var gif = dir + "koala1.gif";

            img    = Image.FromFile(gif, true);
            format = CommonUtils.ImageUtils.GetImageFormat(img);
            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Gif);
            img.Dispose();

            var tiff = dir + "koala1.tif";

            img    = Image.FromFile(tiff, true);
            format = CommonUtils.ImageUtils.GetImageFormat(img);
            Assert.IsTrue(format == System.Drawing.Imaging.ImageFormat.Tiff);
            img.Dispose();
        }