private bool HandleMouseMove(int pxX, int pxY, Toolbox.ToolType tool) { if (m_sprite == null || pxX < 0 || pxY < 0) { return(false); } // Convert screen pixel (x,y) to sprite pixel index (x,y). int pxSpriteX = pxX / BigBitmapPixelSize; int pxSpriteY = pxY / BigBitmapPixelSize; // Ignore if pixel is outside bounds of current sprite. if (pxSpriteX >= m_sprite.PixelWidth || pxSpriteY >= m_sprite.PixelHeight) { return(false); } if (tool == Toolbox.ToolType.FloodFill) { return(m_sprite.FloodFillClick(pxSpriteX, pxSpriteY)); } // Convert sprite pixel coords (x,y) into tile index (x,y) and tile pixel coords (x,y). int tileX = pxSpriteX / Tile.TileSize; int pxTileX = pxSpriteX % Tile.TileSize; int tileY = pxSpriteY / Tile.TileSize; int pxTileY = pxSpriteY % Tile.TileSize; int nTileIndex = (tileY * m_sprite.TileWidth) + tileX; Palette p = m_parent.ActivePalette(); if (tool == Toolbox.ToolType.Eyedropper) { int nCurrColor = m_sprite.GetPixel(pxSpriteX, pxSpriteY); if (nCurrColor == p.CurrentColor()) { return(false); } p.SetCurrentColor(nCurrColor); return(true); } Tile t = m_sprite.GetTile(nTileIndex); int nColor = (tool == Toolbox.ToolType.Eraser ? 0 : p.CurrentColor()); // Same color - no need to update. if (t.GetPixel(pxTileX, pxTileY) == nColor) { return(false); } // Set the new color. t.SetPixel(pxTileX, pxTileY, nColor); return(true); }