Example #1
0
        public Image GetImage(bool pGridOnMaps)
        {
            Bitmap   vBuff = new Bitmap(this.Width * Tile.WIDTH_PX, this.Height * Tile.HEIGHT_PX);
            Graphics vG    = Graphics.FromImage(vBuff);

            try {
                for (int y = 0; y < this.Height; y++)
                {
                    for (int x = 0; x < this.Width; x++)
                    {
                        if (this.mMatrix[x, y] != null)
                        {
                            MapBucket vOld = this.mMatrix[x, y];
                            if (vOld.mTile != null)
                            {
                                vG.DrawImageUnscaled(vOld.mTile.Image, x * Tile.WIDTH_PX, y * Tile.HEIGHT_PX);
                            }
                        }
                    }
                }

                if (pGridOnMaps)
                {
                    DrawingLogic.DrawGrid(vG, new Rectangle(0, 0, vBuff.Width, vBuff.Height), Pens.LightGray, this.Width, this.Height);
                }
            }
            finally {
                vG.Dispose();
                vG = null;
            }

            return(vBuff);
        }
        public static Bitmap CopyAndResize(Bitmap pSource, int pTargetWidth, int pTargetHeight)
        {
            Bitmap vTarget = new Bitmap(pTargetWidth, pTargetHeight);

            using (Graphics vG = Graphics.FromImage(vTarget)) {
                DrawingLogic.SetGraphicsNoInterpol(vG);
                vG.DrawImage(pSource, 0, 0, vTarget.Width, vTarget.Height);
            }
            return(vTarget);
        }
Example #3
0
        public static Image GetRomAsImageUnscaled(string pFilename)
        {
            int vFileLength = (int)(new FileInfo(pFilename).Length);
            int vTileH      = 14;

            using (BinaryReader vReader = new BinaryReader(new FileStream(pFilename, FileMode.Open, FileAccess.Read))) {
                byte[] vBuff      = new byte[READ_BUFFER_LENGTH];
                int    vReadBytes = 0;

                Bitmap   vBitOutput = new Bitmap(8 * vTileH, 8 * (1 + ((vFileLength / (2 * 8)) * 8) / (8 * vTileH)));
                Graphics vGraphx    = Graphics.FromImage(vBitOutput);
                DrawingLogic.SetGraphicsNoInterpol(vGraphx);


                Bitmap vBitBuff = new Bitmap(8, 8);

                int vCounter = 0;
                while ((vReadBytes = vReader.Read(vBuff, 0, READ_BUFFER_LENGTH)) > 0)
                {
                    for (int line = 0; line < 8; line++)
                    {
                        for (int pix = 0; pix < 8; pix++)
                        {
                            int vVal = 0;
                            vVal = vVal | (0x01 & (vBuff[2 * line] >> (8 - 1 - pix)));
                            vVal = vVal | (0x02 & ((vBuff[2 * line + 1] >> (8 - 1 - pix))) << 1);

                            Color vColor = GetColorFromPalette(vVal);
                            vBitBuff.SetPixel(pix, line, vColor);
                        }
                    }

                    if (((vCounter * 8) / vBitOutput.Width) * 8 >= vBitOutput.Height)
                    {
                        break;
                    }

                    int x = (vCounter * 8) % vBitOutput.Width;
                    int y = 8 * ((vCounter * 8) / vBitOutput.Width);

                    vGraphx.DrawImageUnscaled(vBitBuff, x, y);


                    vCounter++;
                }

                vGraphx.Dispose();

                return(vBitOutput);
            }
        }
Example #4
0
        public static Image GetRomAsImage(string pFilename, int pZoomFactor)
        {
            Bitmap vBmp = (Bitmap)GetRomAsImageUnscaled(pFilename);

            if (pZoomFactor == 1)
            {
                return(vBmp);
            }

            Bitmap   vResult = new Bitmap(vBmp.Width * pZoomFactor, vBmp.Height * pZoomFactor);
            Graphics vGraphx = Graphics.FromImage(vResult);

            DrawingLogic.SetGraphicsNoInterpol(vGraphx);

            vGraphx.DrawImage(vBmp, 0, 0, vResult.Width, vResult.Height);

            vGraphx.Dispose();
            vBmp.Dispose();

            return(vResult);
        }