void MakeClassicTextures(Bitmap bmp)
        {
            int  elemSize = bmp.Width / 16;
            Size size     = new Size(tileSize, tileSize);

            terrainBmp    = new Bitmap(tileSize * 2, tileSize);
            terrainPixels = new FastBitmap(terrainBmp, true, false);

            // Precompute the scaled background
            using (FastBitmap src = new FastBitmap(bmp, true, true)) {
                Drawer2DExt.DrawScaledPixels(src, terrainPixels, size,
                                             new Rectangle(2 * elemSize, 0, elemSize, elemSize),
                                             new Rectangle(tileSize, 0, tileSize, tileSize), 128, 64);
                Drawer2DExt.DrawScaledPixels(src, terrainPixels, size,
                                             new Rectangle(1 * elemSize, 0, elemSize, elemSize),
                                             new Rectangle(0, 0, tileSize, tileSize), 96, 96);
            }
        }
示例#2
0
        void ClearTile(int x, int y, int width, int height, int srcX,
                       byte scaleA, byte scaleB, FastBitmap dst)
        {
            if (x >= Width || y >= Height)
            {
                return;
            }
            Rectangle srcRect = new Rectangle(srcX, 0, elemSize, elemSize);
            const int tileSize = 48;
            Size      size = new Size(tileSize, tileSize);
            int       xOrig = x, xMax = x + width, yMax = y + height;

            for ( ; y < yMax; y += tileSize)
            {
                for (x = xOrig; x < xMax; x += tileSize)
                {
                    int x2 = Math.Min(x + tileSize, Math.Min(xMax, Width));
                    int y2 = Math.Min(y + tileSize, Math.Min(yMax, Height));

                    Rectangle dstRect = new Rectangle(x, y, x2 - x, y2 - y);
                    Drawer2DExt.DrawScaledPixels(terrainPixels, dst, size, srcRect, dstRect, scaleA, scaleB);
                }
            }
        }