Ejemplo n.º 1
0
        public async Task<ImageInfo[]> LoadFromDbAsync(string dbFileName)
        {
            var file = await FileSystem.Current.GetFileFromPathAsync(dbFileName).ConfigureAwait(false);
            if (file == null)
                throw new FileNotFoundException();
            using (var fs = await file.OpenAsync(FileAccess.Read).ConfigureAwait(false))
            using (var gz = new GZipStream(fs, CompressionMode.Decompress))
            using (var br = new BinaryReader(gz))
            {
                long count = br.ReadInt32();
                _info = new ImageInfo[count];

                for (var i = 0; i < count; i++)
                {
                    var hash = br.ReadUInt64();
                    var titleId = br.ReadUInt16();
                    var episodeId = br.ReadUInt16();
                    var frame = br.ReadUInt32();
                    _info[i] = new ImageInfo
                    {
                        Hash = hash,
                        TitleId = titleId,
                        EpisodeId = episodeId,
                        Frame = frame
                    };
                }
            }
            return _info;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 該当する画像ベクトルを持つ画像の情報を返します
 /// </summary>
 /// <param name="vector">画像ベクトル</param>
 /// <returns>同じ画像ベクトルを持つ画像群</returns>
 public ImageInfo[] GetImageInfo(ulong vector)
 {
     int min = 0;
     int max = _info.Length - 1;
     int mid;
     int p = 0;
     bool found = false;
     while (min <= max)
     {
         mid = min + (max - min) / 2;
         if (_info[mid].Hash == vector)
         {
             p = mid;
             found = true;
             break;
         }
         else if (_info[mid].Hash < vector)
         {
             min = mid + 1;
         }
         else if (_info[mid].Hash > vector)
         {
             max = mid - 1;
         }
     }
     // 見つからなければ空の配列を返す
     if (!found)
     {
         return new ImageInfo[] { };
     }
     // 見つかったら同じvectorを持つ画像情報をすべて返す
     // (_info内は Hash をキーにしてソート済み)
     min = max = p;
     while (min >= 0 && _info[min].Hash == vector)
     {
         min--;
     }
     while (max < _info.Length && _info[max].Hash == vector)
     {
         max++;
     }
     ImageInfo[] result = new ImageInfo[max - min - 1];
     for (int i = min + 1; i < max; i++)
     {
         result[i - min - 1] = _info[i];
     }
     return result;
 }
Ejemplo n.º 3
0
 public ImageSearch(ImageInfo[] info)
 {
     _info = info;
 }
Ejemplo n.º 4
0
 protected ImageSearch(ImageInfo[] info)
 {
     _info = info;
 }
Ejemplo n.º 5
0
        public ImageInfo[] LoadFromDb(string dbFileName)
        {
            using (FileStream fs = new FileStream(dbFileName, FileMode.Open, FileAccess.Read))
            {
                using (GZipStream gz = new GZipStream(fs, CompressionMode.Decompress))
                {
                    using (BinaryReader br = new BinaryReader(gz))
                    {
                        long count = br.ReadInt32();
                        _info = new ImageInfo[count];

                        for (int i = 0; i < count; i++)
                        {
                            ulong hash = br.ReadUInt64();
                            UInt16 titleId = br.ReadUInt16();
                            UInt16 episodeId = br.ReadUInt16();
                            UInt32 frame = br.ReadUInt32();
                            _info[i] = new ImageInfo
                            {
                                Hash = hash,
                                TitleId = titleId,
                                EpisodeId = episodeId,
                                Frame = frame
                            };
                        }
                    }

                }
            }
            return _info;
        }