Beispiel #1
0
 public static void drawLine(Bmp bmp, int x1, int y1, int x2, int y2, Bmp.Dot dot, int r)
 {
     for (int bx = -r; bx <= r; bx++)
     {
         for (int by = -r; by <= r; by++)
         {
             bmp.drawLine(x1 + bx, y1 + by, x2 + bx, y2 + by, dot);
         }
     }
 }
Beispiel #2
0
        public static void drawDigit(Bmp dest, int l, int t, Color digColor, int dig)
        {
            for (int x = 0; x < 20; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    Bmp.Dot dot = getBmpDigits().table.get(dig * 20 + x, y);

                    if (dot.r != 255)                     // ? 数字の部分
                    {
                        dest.table.set(l + x, t + y, Bmp.Dot.getDot(digColor));
                    }
                }
            }
        }
        private Bitmap Make字幕(string line)
        {
            Bmp.Dot dotBack = new Bmp.Dot(0, 0, 0, 0);
            Bmp.Dot dotExte = new Bmp.Dot(255, 0, 0, 0);
            Bmp.Dot dotInte = new Bmp.Dot(255, 255, 255, 255);

            Bmp bmp;

            using (Bitmap b = new Bitmap(10000, 400))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.FillRectangle(Brushes.Black, 0f, 0f, (float)b.Width, (float)b.Height);
                    g.DrawString(line, new Font("メイリオ", 200f, FontStyle.Regular), Brushes.White, 50f, 50f);
                }
                bmp = Bmp.create(b);
            }

            bmp.select(dot => dot.r < 128 ? dotBack : dotInte);

            {
                Rect rect = bmp.getRect(dot => dot.IsSame(dotInte));

                Gnd.i.logger.writeLine("rect.l: " + rect.l);
                Gnd.i.logger.writeLine("rect.t: " + rect.t);
                Gnd.i.logger.writeLine("rect.r: " + rect.r);
                Gnd.i.logger.writeLine("rect.b: " + rect.b);

                bmp = bmp.getRectBmp(
                    IntTools.toInt(rect.l),
                    IntTools.toInt(rect.t),
                    IntTools.toInt(rect.w),
                    IntTools.toInt(rect.h)
                    );
            }

            Bmp bmpExte;

            bmpExte = bmp.copy();
            bmpExte.select(dot => dot.IsSame(dotInte) ? dotExte : dotBack);

            using (Bitmap b = new Bitmap(bmp.table.w + 60, bmp.table.h + 60))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.Clear(Color.Transparent);

                    {
                        Bitmap be = bmpExte.getBitmap();

                        for (int c = 0; c < 40; c++)
                        {
                            g.DrawImage(be, 10 + c, 10);
                            g.DrawImage(be, 10 + c, 49);
                            g.DrawImage(be, 10, 10 + c);
                            g.DrawImage(be, 49, 10 + c);
                        }
                    }

                    g.DrawImage(bmp.getBitmap(), 30, 30);
                }
                bmp = Bmp.create(b);
            }

            {
                Rect rect = bmp.getRect(dot => dot.IsSame(dotBack) == false);

                bmp = bmp.getRectBmp(
                    IntTools.toInt(rect.l),
                    IntTools.toInt(rect.t),
                    IntTools.toInt(rect.w),
                    IntTools.toInt(rect.h)
                    );
            }

            bmp = bmp.addMargin(10, 10, 10, 10, dotBack);
            bmp = bmp.expand(
                IntTools.toInt(bmp.table.w / 3.0),
                IntTools.toInt(bmp.table.h / 3.0)
                );

            {
                Rect rect = bmp.getRect(dot => dot.IsSame(dotBack) == false);

                bmp = bmp.getRectBmp(
                    IntTools.toInt(rect.l),
                    IntTools.toInt(rect.t),
                    IntTools.toInt(rect.w),
                    IntTools.toInt(rect.h)
                    );
            }

            {
                int w;
                int h;

                h = IntTools.toInt(Img_H * 0.08);
                w = IntTools.toInt(h * bmp.table.w * 1.0 / bmp.table.h);

                w = Math.Min(w, Img_W);

                bmp = bmp.expand(w, h);
            }

            return(bmp.getBitmap());
        }