Beispiel #1
0
        public static void Paste(Canvas2 dest, Canvas2 src, double l, double t, double w, double h)
        {
#if true
            const double MARGIN = 10;

            if (w < src.GetWidth() + MARGIN || h < src.GetHeight() + MARGIN)
            {
                src = Expand(src, (int)(w * 0.99), (int)(h * 0.99));
            }

            using (Graphics g = dest.GetGraphics())
            {
                g.DrawImage(src.GetImage(), (float)l, (float)t, (float)w, (float)h);
            }
#else // 試していない。
            using (Graphics g = dest.GetGraphics())
            {
                g.DrawImage(
                    src.GetImage(),
                    new PointF[]
                {
                    new PointF((float)l, (float)t),
                    new PointF((float)(l + w), (float)t),
                    new PointF((float)l, (float)(t + h)),
                }
                    );
            }
#endif
        }
Beispiel #2
0
        private static Canvas2 BlurOnce(Canvas2 canvas, int phase)
        {
            int w = canvas.GetWidth();
            int h = canvas.GetHeight();

            Canvas2 dest = new Canvas2(w, h);

            using (Graphics g = dest.GetGraphics())
            {
                g.DrawImage(canvas.GetImage(), 0, 0);

                for (int count = 0; count < 8; count++)
                {
                    int direction = (count + phase) % 8;

                    int xa = DIRECTIONS[direction, 0];
                    int ya = DIRECTIONS[direction, 1];

                    g.DrawImage(
                        canvas.GetImage(),
                        new Rectangle(xa, ya, w, h),
                        0, 0, w, h,
                        GraphicsUnit.Pixel,
                        GetIA_Alpha(1.0 / (2.0 + count))
                        );
                }
            }
            return(dest);
        }
Beispiel #3
0
 public static void Paste(Canvas2 dest, Canvas2 src)
 {
     using (Graphics g = dest.GetGraphics(false))
     {
         g.DrawImage(src.GetImage(), 0, 0, dest.GetWidth(), dest.GetHeight());
     }
 }
Beispiel #4
0
        public static Canvas2 Expand(Canvas2 canvas, int w, int h)
        {
            Canvas2 dest = new Canvas2(w, h);

            using (Graphics g = dest.GetGraphics())
            {
                g.DrawImage(canvas.GetImage(), 0, 0, w, h);
            }
            return(dest);
        }
Beispiel #5
0
        public static Canvas2 PutMargin(Canvas2 canvas, int xMargin, int yMargin)
        {
            Canvas2 dest = new Canvas2(canvas.GetWidth() + xMargin * 2, canvas.GetHeight() + yMargin * 2);

            using (Graphics g = dest.GetGraphics(false))
            {
                g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, dest.GetWidth(), dest.GetHeight());
                g.DrawImage(canvas.GetImage(), xMargin, yMargin, canvas.GetWidth(), canvas.GetHeight());
            }
            return(dest);
        }
Beispiel #6
0
        public static Canvas2 PutMargin(Canvas2 canvas)
        {
            const int MARGIN = 10;

            Canvas2 dest = new Canvas2(canvas.GetWidth() + MARGIN * 2, canvas.GetHeight() + MARGIN * 2);

            using (Graphics g = dest.GetGraphics(false))
            {
                g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, dest.GetWidth(), dest.GetHeight());
                g.DrawImage(canvas.GetImage(), MARGIN, MARGIN, canvas.GetWidth(), canvas.GetHeight());
            }
            return(dest);
        }
Beispiel #7
0
        public static void Filter_Color(Canvas2 canvas, Color color, double a)
        {
            Canvas2 maskImg = new Canvas2(canvas.GetWidth(), canvas.GetHeight());

            using (Graphics g = maskImg.GetGraphics(false))
            {
                g.FillRectangle(new SolidBrush(color), 0, 0, maskImg.GetWidth(), maskImg.GetHeight());
            }
            using (Graphics g = canvas.GetGraphics())
            {
                g.DrawImage(
                    maskImg.GetImage(),
                    new Rectangle(0, 0, canvas.GetWidth(), canvas.GetHeight()),
                    0, 0, maskImg.GetWidth(), maskImg.GetHeight(),
                    GraphicsUnit.Pixel,
                    GetIA_Alpha(a)
                    );
            }
        }
Beispiel #8
0
        public static void Filter(Canvas2 canvas, Color color, double a)
        {
            int w = canvas.GetWidth();
            int h = canvas.GetHeight();

            Canvas2 mask = new Canvas2(w, h);

            using (Graphics g = mask.GetGraphics(false))
            {
                g.FillRectangle(new SolidBrush(color), 0, 0, w, h);
            }
            using (Graphics g = canvas.GetGraphics())
            {
                g.DrawImage(
                    mask.GetImage(),
                    new Rectangle(0, 0, w, h),
                    0, 0, w, h,
                    GraphicsUnit.Pixel,
                    GetIA_Alpha(a)
                    );
            }
        }
Beispiel #9
0
        public void DrawTo(PictureData picture, int frame, int frameNum)
        {
            double sec = frame * 1.0 / VideoData.FPS;

            this.Wave.SetWavPart((int)((sec + AUDIO_DELAY_SEC) * this.Wave.WavHz));

            List <double> spectra = new List <double>();
            int           hz      = 10;

            for (int c = 1; c <= 9; c++)
            {
                for (int d = 0; d < 10; d++)
                {
                    double spectrum = 0.0;

                    for (int i = 0; i < c; i++)
                    {
                        spectrum = Math.Max(spectrum, this.Wave.GetSpectrum(hz));
                        hz      += 10;
                    }

                    spectrum /= 30.0;                     // 要調整
                    spectrum  = Vf(spectrum);

                    spectra.Add(spectrum);
                }
            }
            for (int i = 0; i < spectra.Count; i++)
            {
                double v = this.ShadowSpectra[i];

                v -= 0.01;
                v  = Math.Max(v, spectra[i]);

                this.ShadowSpectra[i] = v;
            }

            Canvas2 dest = new Canvas2(picture.GetFrame().GetWidth(), picture.GetFrame().GetHeight());

            using (Graphics g = dest.GetGraphics(false))
            {
                g.FillRectangle(new SolidBrush(Color.FromArgb(64, 0, 0, 0)), 0, 0, dest.GetWidth(), dest.GetHeight());

                int dr_l = 10;
                int dr_t = 10;
                int dr_w = dest.GetWidth() - 20;
                int dr_h = dest.GetHeight() - 20;

                for (int i = 0; i < spectra.Count; i++)
                {
                    int x1 = (((i * 3 + 0) * dr_w) / (spectra.Count * 3 - 2));
                    int x2 = (((i * 3 + 1) * dr_w) / (spectra.Count * 3 - 2));
                    int w  = x2 - x1;

                    double v1 = this.ShadowSpectra[i];
                    double v2 = spectra[i];

                    v1 /= 2.0;                     // 要調整
                    v2 /= 2.0;                     // 要調整

                    int h1 = DoubleTools.ToInt(v1 * dr_h);
                    int h2 = DoubleTools.ToInt(v2 * dr_h);

                    int y1 = dr_h - h1;
                    int y2 = dr_h - h2;

                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, 255, 255, 255)),
                                    dr_l + x1, dr_t + y1, w, h1);
                    g.FillRectangle(new SolidBrush(Color.White),
                                    dr_l + x1, dr_t + y2, w, h2);
                }
            }
            using (Graphics g = picture.GetFrame().GetGraphics(false))
            {
                g.DrawImage(dest.GetImage(), 0, 0);
            }
        }