コード例 #1
0
ファイル: EditVsp.cs プロジェクト: resonancellc/verge3
        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);
                }
            }
        }
コード例 #2
0
ファイル: EditVsp.cs プロジェクト: resonancellc/verge3
        public void paste()
        {
            if (!WindowsClipboard.IsImage)
            {
                return;
            }

            if (!bSelection)
            {
                return;
            }

            pr2.IRenderImage img = WindowsClipboard.getImage();

            int tx = img.Width / 16;
            int ty = img.Height / 16;

            Selection s = originalSelection;

            this.selection = originalSelection.copy();

            if (tx != s.width)
            {
                return;
            }
            if (ty != s.height)
            {
                return;
            }

            Operations.OperationManager om = Global.opManager;
            om.beginGroup("VSP Manager: Paste Tiledata");

            Ops.SetTiledataGroup stdg = new Ops.SetTiledataGroup(Global.ActiveVsp);

            int y0 = s.y;
            int x0 = s.x;

            int[] arrImg = img.GetArray();
            for (int y = 0; y < s.height; y++)
            {
                for (int x = 0; x < s.width; x++)
                {
                    int t = (s.y + y) * TilesWide + s.x + x;
                    stdg.addRecord(t, Global.Misc.sliceIntArrayImage(arrImg, img.Width, x * 16, y * 16, 16, 16));
                }
            }

            om.add(stdg);
            om.endGroupExec();


            img.Dispose();
            Invalidate();
        }
コード例 #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);
        }