render() public static method

public static render ( pr2 dest, int x, int y, pr2 src, bool drawZero ) : void
dest pr2
x int
y int
src pr2
drawZero bool
return void
Ejemplo n.º 1
0
        public void copy()
        {
            if (!bSelection)
            {
                return;
            }

            Selection s = originalSelection;

            if (s.height > 0 && s.width > 0)
            {
                using (pr2.IRenderImage img = pr2.RenderImage.Create(s.width * 16, s.height * 16)) {
                    int y0 = s.y;
                    int x0 = s.x;
                    for (int y = 0; y < s.height; y++)
                    {
                        for (int x = 0; x < s.width; x++)
                        {
                            if (!s.getPoint(x0 + x, y0 + y))
                            {
                                continue;
                            }
                            int tileIndex = (y0 + y) * TilesWide + x + x0;
                            Render.render(img, x * 16, y * 16, Global.ActiveVsp.GetTile(tileIndex).Image, true);
                        }
                    }

                    WindowsClipboard.setImage(img);
                }
            }
        }
Ejemplo n.º 2
0
        private unsafe void paint(Graphics g)
        {
            const int BLACK = unchecked ((int)0xFF000000);

            g.PixelOffsetMode   = PixelOffsetMode.Half;
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            Bitmap bmp = Render.createBitmap(16, 16);

            using (pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmp)) {
                if (TileSourceType == SourceType.Vsp)
                {
                    if (active_tile != null)
                    {
                        if (!bAnimate)
                        {
                            Render.render(img, 0, 0, active_tile.Image, true);
                        }
                        else
                        {
                            int frame = Global.FrameCalc.getframe(atx);
                            Render.render(img, 0, 0, Global.ActiveMap.vsp.GetTile(frame).Image, true);
                        }
                    }
                    else
                    {
                        img.Clear(BLACK);
                    }
                }
                else
                {
                    if (active_obstile != null)
                    {
                        Render.renderObsTile(img, 0, 0, active_obstile.Image, true, Preferences.Current.ObsColor);
                    }
                    else
                    {
                        img.Clear(BLACK);
                    }
                }
            }
            g.DrawImage(bmp, 0, 0, Width, Height);
            bmp.Dispose();
        }
Ejemplo n.º 3
0
        public unsafe void ExportToClipboard(int GridSize)
        {
            int    th  = tileCount / 20 + 1;
            int    h   = th * (16 + GridSize) + GridSize;
            int    w   = 320 + (GridSize * 21);
            Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);

            using (pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmp)) {
                // render stuffs
                for (int y = 0; y < th; y++)
                {
                    for (int x = 0; x < 20 && y * 20 + x < tileCount; x++)
                    {
                        Render.render(img, GridSize + x * (16 + GridSize), GridSize + y * (16 + GridSize), GetTile(y * 20 + x).Image, true);
                    }
                }
            }

            WindowsClipboard.setBitmap(bmp);
        }
Ejemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (vsp == null)
            {
                return;
            }

            const int WHITE = unchecked ((int)0xFFFFFFFF);

            e.Graphics.PixelOffsetMode   = PixelOffsetMode.Half;
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            CalculateScrollValues();

            Bitmap bmp = new Bitmap(TilesWide * 16, TilesHigh * 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using (pr2.IRenderImage qimg = pr2.RenderImage.LockBitmap(bmp)) {
                if (ControllerType == VSPController.ControllerType.VSP)
                {
                    int row = 0, col = 0;
                    for (int i = scrollOffset / 16 * 20; i < vsp.Tiles.Count; i++)
                    {
                        Render.render(qimg, col * 16, row * 16, vsp.GetTile(i).Image, true);
                        if (i == st0)
                        {
                            if (controller_mode != VSPController.ControllerMode.ViewOnly)
                            {
                                Render.renderBox(qimg, col * 16, row * 16, 16, 16, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 1, row * 16 + 1, 14, 14, WHITE, Render.PixelOp.Src);
                            }
                        }
                        if (i == st1)
                        {
                            if (controller_mode == VSPController.ControllerMode.SelectorDual)
                            {
                                Render.renderBox(qimg, col * 16 + 2, row * 16 + 2, 12, 12, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 3, row * 16 + 3, 10, 10, WHITE, Render.PixelOp.Src);
                            }
                        }
                        col++;
                        if (col == TilesWide)
                        {
                            col = 0;
                            row++;
                            if (row == TilesHigh)
                            {
                                break;
                            }
                        }
                    }
                }
                else if (ControllerType == VSPController.ControllerType.Obstruction)
                {
                    // render obs tiles
                    int row = 0, col = 0;
                    for (int i = scrollOffset / 16 * 20; i < vsp.ObstructionTiles.Count; i++)
                    {
                        VspObstructionTile vot = ((VspObstructionTile)vsp.ObstructionTiles[i]);
                        Render.renderObsTile(qimg, col * 16, row * 16, vot.Image, true, Preferences.Current.ObsColor);
                        if (i == st0)
                        {
                            if (controller_mode != VSPController.ControllerMode.ViewOnly)
                            {
                                Render.renderBox(qimg, col * 16, row * 16, 16, 16, WHITE, Render.PixelOp.Src);
                                Render.renderBox(qimg, col * 16 + 1, row * 16 + 1, 14, 14, WHITE, Render.PixelOp.Src);
                            }
                        }
                        col++;
                        if (col == TilesWide)
                        {
                            col = 0;
                            row++;
                            if (row == TilesHigh)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            e.Graphics.DrawImage(bmp, 0, 0, Size.Width, Size.Height);
            bmp.Dispose();
        }
Ejemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (parent == null)
            {
                e.Graphics.FillRectangle(System.Drawing.Brushes.Black, e.ClipRectangle.Left, e.ClipRectangle.Right, e.ClipRectangle.Width, e.ClipRectangle.Height);
                return;
            }

            e.Graphics.PixelOffsetMode   = PixelOffsetMode.Half;
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            Bitmap bmp = new Bitmap(TilesWide * 16, (TilesHigh + 1) * 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            pr2.IRenderImage qimg = pr2.RenderImage.LockBitmap(bmp);

            int row = 0, col = 0;

            for (int i = scrollOffset; i < parent.vsp.Tiles.Count; i++)
            {
                Render.render(qimg, col * 16, row * 16, parent.vsp.GetTile(i).Image, true);

                if (bSelection)
                {
                    int xx = col;
                    int yy = row + logicalRow;
                    if (selection.getPoint(xx, yy))
                    {
                        int tile = originalSelection.getPointIntegerValue(xx - selection.x + originalSelection.x, yy - selection.y + originalSelection.y, this);
                        if (tile != -1)
                        {
                            Render.render(qimg, col * 16, row * 16, parent.vsp.GetTile(tile).Image, true);
                        }
                    }
                }

                col++;
                if (col == TilesWide)
                {
                    col = 0;
                    row++;
                    if (row == TilesHigh)
                    {
                        break;
                    }
                }
            }

            //render the empty area
            while (row != TilesHigh + 1)
            {
                while (col != TilesWide)
                {
                    Render.renderColoredStippleTile(qimg, col * 16, row * 16, Render.makeColor(0, 0, 0), Render.makeColor(192, 192, 192));
                    col++;
                }
                col = 0;
                row++;
            }

            qimg.Dispose();
            e.Graphics.DrawImage(bmp, 0, 0, TilesWide * 16, (TilesHigh + 1) * 16);
            bmp.Dispose();


            e.Graphics.PixelOffsetMode = PixelOffsetMode.Default;

            if (bSelectingRect)
            {
                Point p0  = (new Point(Math.Min(mtx, mtx1), Math.Min(mty, mty1)));
                Point p1  = (new Point(Math.Max(mtx, mtx1), Math.Max(mty, mty1)));
                Pen   pen = new Pen(Color.White);
                pen.DashStyle = DashStyle.Dash;
                pen.Width     = 1;
                e.Graphics.DrawRectangle(pen, p0.X * 16, (p0.Y - logicalRow) * 16, (p1.X - p0.X) * 16, (p1.Y - p0.Y) * 16);
                pen.Dispose();
            }
            if (bSelection)
            {
                GraphicsPath gp = new GraphicsPath();

                selection.updateGraphicsPath(gp, 16, 0, -logicalRow * 16);
                Pen pen = new Pen(Color.FromArgb(128, 0, 0, 0));
                pen.Width     = 5;
                pen.DashStyle = DashStyle.Solid;
                e.Graphics.TranslateTransform(1.0f, 1.0f);
                e.Graphics.DrawPath(pen, gp);
                e.Graphics.TranslateTransform(-1.0f, -1.0f);

                pen.Color     = Color.White;
                pen.Width     = 1;
                pen.DashStyle = DashStyle.Dash;
                e.Graphics.DrawPath(pen, gp);
                pen.Dispose();
                gp.Dispose();
            }
        }
Ejemplo n.º 6
0
        private void renderTileLayer(pr2.IRenderImage backBuffer, MapLayer layer, Vsp24 vsp, int px, int py, bool drawZero)
        {
            int mtx  = px / 16;
            int mty  = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;

            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth  = layer.Width;
            int layerHeight = layer.Height;
            int cpx         = -mtox;
            int cpy         = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            short[] tileMap = layer.Data;
            if (Global.RenderOptions.bTranslucentEffects)
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if ((drawZero || tile != 0) && tile < vsp.tileCount)
                        {
                            Render.renderAlpha(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, 100 - layer.Translucency, false);
                        }
                    }
                }
            }
            else
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if (drawZero || tile != 0 && tile < vsp.tileCount)
                        {
                            Render.render(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, false);
                        }
                    }
                }
            }
        }