From b6573a1de762b519dbf2b2c800059afae76fc7b6 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 11 Nov 2015 19:22:34 -0800 Subject: [PATCH] Store unaltered image If I somehow want to reload entities from OWSE without regenerating the map image. Entity images are a little more opaque. 40%->66% --- pk3DS/Subforms/MapPermView.cs | 101 ++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/pk3DS/Subforms/MapPermView.cs b/pk3DS/Subforms/MapPermView.cs index e3b6b84..34fb26f 100644 --- a/pk3DS/Subforms/MapPermView.cs +++ b/pk3DS/Subforms/MapPermView.cs @@ -38,60 +38,67 @@ public Image getMapImage(bool crop = false, bool entity = true) mapScale = (int)NUD_Scale.Value; Image img = mm.Preview(mapScale, (int)NUD_Flavor.Value); + baseImage = (Image)img.Clone(); if (entity && mapScale == 8) - { - const float opacity = 0.5f; - // Overlay every... overworld entity - foreach (var e in OWSE.CurrentZone.Entities.Furniture) - { - int x = e.X; - int y = e.Y; - for (int sx = 0; sx < e.WX; sx++) // Stretch X - for (int sy = 0; sy < e.WY; sy++) // Stretch Y - try { Util.LayerImage(img, Resources.F, (x+sx)*mapScale, (y+sy)*mapScale, opacity); } - catch { } - } - foreach (var e in OWSE.CurrentZone.Entities.NPCs) - { - int x = e.X; - int y = e.Y; - try { Util.LayerImage(img, Resources.N, x * mapScale, y * mapScale, opacity); } - catch { } - } - foreach (var e in OWSE.CurrentZone.Entities.Warps) - { - int x = (int)e.pX; // shifted warps look weird - int y = (int)e.pY; // shifted warps look weird - for (int sx = 0; sx < e.Width; sx++) // Stretch X - for (int sy = 0; sy < e.Height; sy++) // Stretch Y - try { Util.LayerImage(img, Resources.W, ((x+sx)*mapScale), ((y+sy)*mapScale), opacity); } - catch { } - } - foreach (var e in OWSE.CurrentZone.Entities.Triggers1) - { - int x = e.X; - int y = e.Y; - for (int sx = 0; sx < e.Width; sx++) // Stretch X - for (int sy = 0; sy < e.Height; sy++) // Stretch Y - try { Util.LayerImage(img, Resources.T1, (x + sx) * mapScale, (y + sy) * mapScale, opacity); } - catch { } - } - foreach (var e in OWSE.CurrentZone.Entities.Triggers2) - { - int x = e.X; - int y = e.Y; - for (int sx = 0; sx < e.Width; sx++) // Stretch X - for (int sy = 0; sy < e.Height; sy++) // Stretch Y - try { Util.LayerImage(img, Resources.T2, (x + sx) * mapScale, (y + sy) * mapScale, opacity); } - catch { } - } - } + img = overlayEntities(img); if (crop) img = Util.TrimBitmap((Bitmap)img); OWSE.mm = mm; return img; } + internal static Image baseImage; + + private Image overlayEntities(Image img) + { + const float opacity = 0.66f; + // Overlay every... overworld entity + foreach (var e in OWSE.CurrentZone.Entities.Furniture) + { + int x = e.X; + int y = e.Y; + for (int sx = 0; sx < e.WX; sx++) // Stretch X + for (int sy = 0; sy < e.WY; sy++) // Stretch Y + try { Util.LayerImage(img, Resources.F, (x + sx) * mapScale, (y + sy) * mapScale, opacity); } + catch { } + } + foreach (var e in OWSE.CurrentZone.Entities.NPCs) + { + int x = e.X; + int y = e.Y; + try { Util.LayerImage(img, Resources.N, x * mapScale, y * mapScale, opacity); } + catch { } + } + foreach (var e in OWSE.CurrentZone.Entities.Warps) + { + int x = (int)e.pX; // shifted warps look weird + int y = (int)e.pY; // shifted warps look weird + for (int sx = 0; sx < e.Width; sx++) // Stretch X + for (int sy = 0; sy < e.Height; sy++) // Stretch Y + try { Util.LayerImage(img, Resources.W, ((x + sx) * mapScale), ((y + sy) * mapScale), opacity); } + catch { } + } + foreach (var e in OWSE.CurrentZone.Entities.Triggers1) + { + int x = e.X; + int y = e.Y; + for (int sx = 0; sx < e.Width; sx++) // Stretch X + for (int sy = 0; sy < e.Height; sy++) // Stretch Y + try { Util.LayerImage(img, Resources.T1, (x + sx) * mapScale, (y + sy) * mapScale, opacity); } + catch { } + } + foreach (var e in OWSE.CurrentZone.Entities.Triggers2) + { + int x = e.X; + int y = e.Y; + for (int sx = 0; sx < e.Width; sx++) // Stretch X + for (int sy = 0; sy < e.Height; sy++) // Stretch Y + try { Util.LayerImage(img, Resources.T2, (x + sx) * mapScale, (y + sy) * mapScale, opacity); } + catch { } + } + return img; + } + // UI private void hoverMap(object sender, MouseEventArgs e) {