コード例 #1
0
        static public bool StaticInit()
        {
            mColorDir = WWMonitorProfile.GetColorDirectory();
            if (mColorDir == null)
            {
                MessageBox.Show("Error: Color Profile Directory is not found!");
                return(false);
            }

            try {
                mMonitorProfileName = WWMonitorProfile.GetMonitorProfile();
            } catch (Exception ex) {
                var w = new WWDescriptionWindow(WWDescriptionWindow.LocalPathToUri("desc/SettingMonitorProfile.html"));
                w.ShowDialog();
                return(false);
            }

            if (mMonitorProfileName == null)
            {
                var w = new WWDescriptionWindow(WWDescriptionWindow.LocalPathToUri("desc/SettingMonitorProfile.html"));
                w.ShowDialog();
                return(false);
            }

            mColorDir = mColorDir + "\\";

            mStaticInitSuccess = SetupColorCtx();
            return(mStaticInitSuccess);
        }
コード例 #2
0
        static private bool SetupColorCtx()
        {
            try {
                mColorCtx[(int)ColorProfileType.sRGB] = new ColorContext(new Uri(mColorDir + ColorProfileName(ColorProfileType.sRGB), UriKind.Absolute));
            } catch (Exception) {
                MessageBox.Show(string.Format("Error: \"{0}\" Color Profile is not found!", ColorProfileName(ColorProfileType.sRGB)));
                return(false);
            }
            try {
                mColorCtx[(int)ColorProfileType.AdobeRGB] = new ColorContext(new Uri(mColorDir + ColorProfileName(ColorProfileType.AdobeRGB), UriKind.Absolute));
            } catch (Exception) {
                var w = new WWDescriptionWindow(WWDescriptionWindow.LocalPathToUri("desc/InstallAdobeRGB.html"));
                w.ShowDialog();
                return(false);
            }
            try {
                mColorCtx[(int)ColorProfileType.Rec709] = new ColorContext(new Uri(mColorDir + ColorProfileName(ColorProfileType.Rec709), UriKind.Absolute));
            } catch (Exception) {
                var w = new WWDescriptionWindow(WWDescriptionWindow.LocalPathToUri("desc/InstallRec709.html"));
                w.ShowDialog();
                return(false);
            }
            try {
                mColorCtx[(int)ColorProfileType.Monitor] = new ColorContext(new Uri(mColorDir + mMonitorProfileName, UriKind.Absolute));
            } catch (Exception) {
                var w = new WWDescriptionWindow(WWDescriptionWindow.LocalPathToUri("desc/SettingMonitorProfile.html"));
                w.ShowDialog();
                return(false);
            }

            return(true);
        }
コード例 #3
0
        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);
        }