smooth zoom - windows forms

Aug 11, 2010 at 7:25 AM

Hi,

In GMap.NET,WindowsForms file GMapControl.cs function DrawMapGDIplus

after

if (t != null)

 {

..

}

add the folowing

 

else

{

 

int ZoomOffset = 0;

 

Tile ParentTile = null;

 

while (ParentTile == null && (Core.Zoom - ZoomOffset) >= 1 && ZoomOffset <= 5)

{

ZoomOffset += 1;

 

int IxDev = (int)Math.Pow(2, ZoomOffset);

ParentTile = Core.Matrix.GetTileWithNoLock(Core.Zoom - ZoomOffset,

new GMap.NET.Point((int)(tilePoint.X / IxDev), (int)(tilePoint.Y / IxDev)));

}

 

if (ParentTile != null)

{

 

int Ix = (int)Math.Pow(2, ZoomOffset);

 

int Xoff = Math.Abs(tilePoint.X - (ParentTile.Pos.X * Ix));

 

int Yoff = Math.Abs(tilePoint.Y - (ParentTile.Pos.Y * Ix));

 

// render tile

 

lock (ParentTile.Overlays)

{

 

foreach (WindowsFormsImage img in ParentTile.Overlays)

{

 

if (img != null && img.Img != null)

{

 

if (!found)

found =

true;

System.Drawing.

RectangleF srcRect =

 

new System.Drawing.RectangleF((float)(Xoff * (img.Img.Width / Ix)),

(

float)(Yoff * (img.Img.Height / Ix)),

(img.Img.Width / Ix),

(img.Img.Height / Ix));

 

ImageAttributes attributes = new ImageAttributes();

attributes.SetWrapMode(

WrapMode.TileFlipXY);

g.DrawImage(img.Img,

 

new System.Drawing.Rectangle(Core.tileRect.X, Core.tileRect.Y, Core.tileRect.Width, Core.tileRect.Height),

srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,

GraphicsUnit.Pixel, attributes);

}

}

}

}

}

 

Working only if !ContinuesMap and !PocketPC

Best regards,

Blaz

Aug 11, 2010 at 11:02 AM

thats really something! Thanks ;}

Aug 11, 2010 at 12:47 PM

It's quite good, but if in CacheOnly mode, tile loading should be implemented, if the tile is not in memory. Because now it only takes the tiles that are memcached.

Best regards,

Blaz

Aug 11, 2010 at 8:55 PM

yes, theres is a lot of space for improvements as always, a never ending saga of great maps ;}

Aug 13, 2010 at 11:32 AM

Hi,

I've seen the code inside the hotbuild.

You should insert the !ContinuesMap check also

because of tilePoint and tileToDraw difference

 

Aug 13, 2010 at 11:44 AM

yeah, but ContinuesMap does not work correctly and i left it for later testing