コード例 #1
0
        public void Preload(IEnumerable <int> indices, DecoderChoice decoderChoice = DecoderChoice.Automatic)
        {
            requestedKeys.Clear();
            var toDelete = new List <int>(frames.Keys);

            foreach (var id in indices)
            {
                var key = VMath.Zmod(id, FrameCount);

                requestedKeys.Add(key);

                if (frames.ContainsKey(key))
                {
                    toDelete.Remove(key);
                }
                else
                {
                    IDecoder decoder = Decoder.SelectFromFile(decoderChoice, files[key], FMemoryPool);
                    decoder.Device = device;
                    frames[key]    = new Frame(files[key].FullName, decoder, FLogger);

                    frames[key].LoadAsync();
                }
            }

            foreach (var d in toDelete)
            {
                frames[d].Dispose();
                frames.Remove(d);
            }
        }
コード例 #2
0
 public static IDecoder SelectFromFile(DecoderChoice decoderChoice, System.IO.FileInfo file, MemoryPool memPool)
 {
     if (decoderChoice == DecoderChoice.Automatic)
     {
         var ext = file.Extension.ToLower();
         decoderChoice = ext.Contains(".dds") ? DecoderChoice.DirectX : DecoderChoice.WIC;
     }
     if (decoderChoice == DecoderChoice.DirectX)
     {
         return(new GPUDecoder());
     }
     else
     {
         return(new WICDecoder(memPool));
     }
 }