stdecden
04-09-2008, 10:27
Salve a tutti,
sto scrivendo un Tilemap-editor e questo é il codice che uso per renderizzare la mappa:
void pnlCenter_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Graphics g = e.Graphics;
if (map != null)
{
for (int y = 0; y < map.TilesY; y++)
{
for (int x = 0; x < map.TilesX; x++)
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.DrawImage(map.Image, new Rectangle(x * map.Tileset.TileWidth, y * map.Tileset.TileHeight, map.Tileset.TileWidth, map.Tileset.TileHeight), new Rectangle(x * map.Tileset.TileWidth, y * map.Tileset.TileHeight, map.Tileset.TileWidth, map.Tileset.TileHeight), GraphicsUnit.Pixel);
}
}
}
}
L' immagine utilizzata é di dimensioni abbastanza grandi (4096 x 4096px), ed i tiles sono di 16x16px.
La visualizzazione é estremamente lenta. Circa 10sec per una finestra 200x200
Qualcuno mi puó suggerire un modo migliore...
sto scrivendo un Tilemap-editor e questo é il codice che uso per renderizzare la mappa:
void pnlCenter_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Graphics g = e.Graphics;
if (map != null)
{
for (int y = 0; y < map.TilesY; y++)
{
for (int x = 0; x < map.TilesX; x++)
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.DrawImage(map.Image, new Rectangle(x * map.Tileset.TileWidth, y * map.Tileset.TileHeight, map.Tileset.TileWidth, map.Tileset.TileHeight), new Rectangle(x * map.Tileset.TileWidth, y * map.Tileset.TileHeight, map.Tileset.TileWidth, map.Tileset.TileHeight), GraphicsUnit.Pixel);
}
}
}
}
L' immagine utilizzata é di dimensioni abbastanza grandi (4096 x 4096px), ed i tiles sono di 16x16px.
La visualizzazione é estremamente lenta. Circa 10sec per una finestra 200x200
Qualcuno mi puó suggerire un modo migliore...