GetBitmap() 공개 메소드

public GetBitmap ( ) : Bitmap
리턴 System.Drawing.Bitmap
        private void RecalcMinMax(MultiTile tile)
        {
            if (tile.isVirtualFloor)
            {
                return;
            }
            if (tile.GetBitmap() == null)
            {
                return;
            }
            int px = tile.Xmod - GapXMod;
            int py = tile.Ymod - GapYMod;

            if (px < xMin)
            {
                xMin = px;
            }
            if (py < yMin)
            {
                yMin = py;
            }
            px += tile.GetBitmap().Width;
            py += tile.GetBitmap().Height;

            if (px > xMax)
            {
                xMax = px;
            }
            if (py > yMax)
            {
                yMax = py;
            }
            if (tile.Z > zMax)
            {
                zMax = tile.Z;
            }
            if (tile.Z < zMin)
            {
                zMin = tile.Z;
            }
            Modified = false;
            xMinOrg  = xMin;
            xMaxOrg  = xMax;
            yMinOrg  = yMin;
            yMaxOrg  = yMax;

            if (Parent.ShowWalkables)
            {
                CalcWalkable();
            }
            if (Parent.ShowDoubleSurface)
            {
                CalcDoubleSurface();
            }
        }
        /// <summary>
        /// Gets <see cref="MultiTile"/> from given Pixel Location
        /// </summary>
        public MultiTile GetSelected(Point mouseLoc, int maxheight, bool drawFloor)
        {
            if (Width == 0 || Height == 0)
            {
                return(null);
            }
            MultiTile selected = null;

            if (mouseLoc != Point.Empty)
            {
                for (int i = Tiles.Count - 1; i >= 0; --i) // inverse for speedup
                {
                    MultiTile tile = Tiles[i];
                    if (tile.isVirtualFloor)
                    {
                        continue;
                    }
                    if (tile.Z > maxheight)
                    {
                        continue;
                    }
                    if ((drawFloor) && (Parent.DrawFloorZ > tile.Z))
                    {
                        continue;
                    }
                    Bitmap bmp = tile.GetBitmap();
                    if (bmp == null)
                    {
                        continue;
                    }
                    int px = tile.Xmod;
                    int py = tile.Ymod;
                    px -= xMin;
                    py -= yMin;
                    if (((mouseLoc.X > px) && (mouseLoc.X < (px + bmp.Width))) &&
                        ((mouseLoc.Y > py) && (mouseLoc.Y < (py + bmp.Height))))
                    {
                        //Check for transparent part
                        Color p = bmp.GetPixel(mouseLoc.X - px, mouseLoc.Y - py);
                        if (!((p.R == 0) && (p.G == 0) && (p.B == 0)))
                        {
                            selected = tile;
                            break;
                        }
                    }
                }
            }
            return(selected);
        }
        /// <summary>
        /// Gets Bitmap of Multi and sets HoverTile
        /// </summary>
        public void GetImage(Graphics gfx, int xoff, int yoff, int maxheight, Point mouseLoc, bool drawFloor, bool forcerefresh)
        {
            if (Width == 0 || Height == 0)
            {
                return;
            }

            if (Modified)
            {
                RecalcMinMax();
            }

            xMin = xMinOrg;
            xMax = xMaxOrg;
            yMin = yMinOrg;
            yMax = yMaxOrg;

            if (drawFloor)
            {
                int floorzmod = -Parent.DrawFloorZ << 2 - 44;
                if (yMin > floorzmod)
                {
                    yMin = floorzmod;
                }
                floorzmod = (Width + Height) * 22 - Parent.DrawFloorZ << 2;
                if (yMaxOrg < floorzmod)
                {
                    yMax = floorzmod;
                }
            }
            Parent.HoverTile = GetSelected(mouseLoc, maxheight, drawFloor);

            Rectangle clipBounds = Rectangle.Round(gfx.ClipBounds);

            for (int i = 0; i < Tiles.Count; ++i)
            {
                MultiTile tile = Tiles[i];
                if (!tile.isVirtualFloor)
                {
                    if (tile.Z > maxheight)
                    {
                        continue;
                    }
                }
                Bitmap bmp = tile.GetBitmap();
                if (bmp == null)
                {
                    continue;
                }
                drawdestRectangle.X      = tile.Xmod;
                drawdestRectangle.Y      = tile.Ymod;
                drawdestRectangle.X     -= xMin + xoff;
                drawdestRectangle.Y     -= yMin + yoff;
                drawdestRectangle.Width  = bmp.Width;
                drawdestRectangle.Height = bmp.Height;

                if (!clipBounds.IntersectsWith(drawdestRectangle))
                {
                    continue;
                }
                if (tile.isVirtualFloor)
                {
                    if (drawFloor)
                    {
                        gfx.DrawImageUnscaled(bmp, drawdestRectangle);
                    }
                }
                else
                {
                    if ((Parent.HoverTile != null) && (Parent.HoverTile == tile))
                    {
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.HoverColor);
                    }
                    else if ((Parent.SelectedTile != null) && (Parent.SelectedTile == tile))
                    {
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.SelectedColor);
                    }
                    else if (tile.Transparent)
                    {
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.TransColor);
                    }
                    else if ((Parent.ShowWalkables) && (tile.Walkable))
                    {
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.StandableColor);
                    }
                    else if ((Parent.ShowDoubleSurface) && (tile.DoubleSurface))
                    {
                        gfx.DrawImage(bmp, drawdestRectangle, 0, 0, drawdestRectangle.Width, drawdestRectangle.Height, GraphicsUnit.Pixel, MultiTile.StandableColor);
                    }
                    else
                    {
                        gfx.DrawImageUnscaled(bmp, drawdestRectangle);
                    }
                }
            }
        }
        private void RecalcMinMax(MultiTile tile)
        {
            if (tile.isVirtualFloor)
                return;
            if (tile.GetBitmap() == null)
                return;
            int px = tile.Xmod - GapXMod;
            int py = tile.Ymod - GapYMod;

            if (px < xMin)
                xMin = px;
            if (py < yMin)
                yMin = py;
            px += tile.GetBitmap().Width;
            py += tile.GetBitmap().Height;

            if (px > xMax)
                xMax = px;
            if (py > yMax)
                yMax = py;
            if (tile.Z > zMax)
                zMax = tile.Z;
            if (tile.Z < zMin)
                zMin = tile.Z;
            Modified = false;
            xMinOrg = xMin;
            xMaxOrg = xMax;
            yMinOrg = yMin;
            yMaxOrg = yMax;

            if (Parent.ShowWalkables)
                CalcWalkable();
            if (Parent.ShowDoubleSurface)
                CalcDoubleSurface();
        }