Example #1
0
        private static void CheckHz()
        {
            long currTime = DDUtils.GetCurrTime();

            HzChaserTime += 16L;             // 16.666 == 60Hz
            HzChaserTime  = LongTools.ToRange(HzChaserTime, currTime - 100L, currTime + 100L);

            while (currTime < HzChaserTime)
            {
                Thread.Sleep(1);
                currTime = DDUtils.GetCurrTime();
            }
            FrameStartTime = currTime;
        }
Example #2
0
        private static void ConvImageJpeg(string rFile, string wFile, string midPathBase)
        {
            int w;
            int h;

            try             // 画像読み込みテスト
            {
                using (Bitmap.FromFile(rFile))
                { }
            }
            catch (Exception e)
            {
                ProcMain.WriteLog(e);

                throw new Exception("画像ファイル読み込みエラー");
            }

            using (Image bmp = Bitmap.FromFile(rFile))
            {
                w = bmp.Width;
                h = bmp.Height;

                bmp.Save(midPathBase + "1.bmp", ImageFormat.Bmp);                 // 透過を無効にしたいだけ、、、
            }

            ProcMain.WriteLog("w: " + w);
            ProcMain.WriteLog("h: " + h);

            if (w < 1 || IntTools.IMAX < w)
            {
                throw new Exception("画像ファイルの幅に問題があります。");
            }

            if (h < 1 || IntTools.IMAX < h)
            {
                throw new Exception("画像ファイルの高さに問題があります。");
            }

            if (Ground.I.画像を二重に表示)
            {
                int mon_w = Ground.I.画像を二重に表示_MonitorW;
                int mon_h = Ground.I.画像を二重に表示_MonitorH;

                // 高さと幅はそれぞれ偶数でなければならない。
                mon_w &= ~1;
                mon_h &= ~1;

                int ww = mon_w;
                int hh;

                {
                    long t = h;
                    t *= mon_w;
                    t /= w;

                    if (mon_h <= t)
                    {
                        hh = (int)t;
                    }
                    else
                    {
                        hh = mon_h;

                        t  = w;
                        t *= mon_h;
                        t /= h;

                        ww = (int)t;
                    }
                }

                string aa;

                if (Ground.I.画像を二重に表示_明るさ == 100)
                {
                    aa = "";
                }
                else
                {
                    aa = ":" + Ground.I.画像を二重に表示_明るさ.ToString("D2");
                }

                int ll = (ww - mon_w) / 2;
                int tt = (hh - mon_h) / 2;

                Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "1w.png /e " + ww + " " + hh +
                    " /C " + ll + " " + tt + " " + mon_w + " " + mon_h +
                    " /BOKASHI 0 0 " + mon_w + " " + mon_h + " " + Ground.I.画像を二重に表示_ぼかし + " 1 " +
                    " /DOTFLTR A R" + aa + " G" + aa + " B" + aa
                    );

                if (File.Exists(midPathBase + "1w.png") == false)
                {
                    throw new Exception("画像処理エラー(1w)");
                }

                ww = mon_w;

                {
                    long t = h;
                    t *= mon_w;
                    t /= w;

                    if (t <= mon_h)
                    {
                        hh = (int)t;
                    }
                    else
                    {
                        hh = mon_h;

                        t  = w;
                        t *= mon_h;
                        t /= h;

                        ww = (int)t;
                    }
                }

                Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "1f.png /e " + ww + " " + hh);

                if (File.Exists(midPathBase + "1f.png") == false)
                {
                    throw new Exception("画像処理エラー(1f)");
                }

                ll = (mon_w - ww) / 2;
                tt = (mon_h - hh) / 2;

                Run("ImgTools.exe /rf " + midPathBase + "1w.png /wf " + midPathBase + "2.png /2 " + midPathBase + "1f.png /PASTE " + ll + " " + tt);
            }
            else
            {
                int ww = IntTools.ToRange(w, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX);
                int hh;

                {
                    long t = h;
                    t *= ww;
                    t /= w;

                    if (Consts.IMAGE_WH_MIN <= t && t <= Consts.IMAGE_WH_MAX)
                    {
                        hh = (int)t;
                    }
                    else
                    {
                        hh = IntTools.ToRange(h, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX);

                        t  = w;
                        t *= hh;
                        t /= h;
                        t  = LongTools.ToRange(t, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX);

                        ww = (int)t;
                    }
                }

                ProcMain.WriteLog("ww.1: " + ww);
                ProcMain.WriteLog("hh.1: " + hh);

                // 高さと幅はそれぞれ偶数でなければならない。
                ww &= ~1;
                hh &= ~1;

                ProcMain.WriteLog("ww.2: " + ww);
                ProcMain.WriteLog("hh.2: " + hh);

                Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "2.png /e " + ww + " " + hh);
            }
            if (File.Exists(midPathBase + "2.png") == false)
            {
                throw new Exception("画像処理エラー(ImgTools)");
            }

            Run("BmpToCsv.exe /J " + Ground.I.JpegQuality + " " + midPathBase + "2.png " + midPathBase + "3.jpg");

            if (File.Exists(midPathBase + "3.jpg") == false)
            {
                throw new Exception("画像処理エラー(BmpToCsv)");
            }

            File.Move(midPathBase + "3.jpg", wFile);
        }