private BitmapSource NextImage(ImgInf imgInf, WWImageRead ir)
        {
            if (imgInf.duration < 0)
            {
                return(null);
            }

            int hr = ir.VReadImage(-1, imgInf.cp, out BitmapSource bi, ref imgInf.duration, ref imgInf.timeStamp);

            if (hr < 0)
            {
                MessageBox.Show(string.Format("Error: {0:x} while reading {1}", hr, imgInf.path));
                return(null);
            }
            return(bi);
        }
        private BitmapSource ReadFromFile(ImgInf imgInf, long timeStamp, WWImageRead ir)
        {
            var ext = System.IO.Path.GetExtension(imgInf.path).ToUpper();

            string[] imgExt = { ".PNG", ".JPG", ".JPEG", ".BMP" };
            if (imgExt.Any(s => s.Equals(ext)))
            {
                // 画像の拡張子の場合。
                imgInf.duration  = -1;
                imgInf.timeStamp = -1;
                return(ir.ColorConvertedRead(imgInf.path, imgInf.cp));
            }

            ir.VReadEnd();

            int hr = ir.VReadStart(imgInf.path);

            if (hr < 0)
            {
                if (hr == WWMFVideoReaderCs.WWMFVideoReader.MF_E_INVALIDMEDIATYPE ||
                    hr == WWMFVideoReaderCs.WWMFVideoReader.MF_E_UNSUPPORTED_BYTESTREAM_TYPE)
                {
                    var w = new WWDescriptionWindow(WWDescriptionWindow.LocalPathToUri("desc/UnsupportedMediaType.html"));
                    w.ShowDialog();
                    return(null);
                }
                else
                {
                    MessageBox.Show(string.Format("Error: {0:x} while reading {1}", hr, imgInf.path));
                    return(null);
                }
            }

            hr = ir.VReadImage(timeStamp, imgInf.cp, out BitmapSource bi, ref imgInf.duration, ref imgInf.timeStamp);
            if (hr < 0)
            {
                MessageBox.Show(string.Format("Error: {0:x} while reading {1}", hr, imgInf.path));
                return(null);
            }
            return(bi);
        }