mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 4.12. Added MapControl.Images project
This commit is contained in:
parent
ccb77b30c9
commit
7d4b2ee68b
|
|
@ -77,57 +77,5 @@ namespace MapControl.Images
|
|||
|
||||
SetWorldImage(image, bitmap, parameters, projection);
|
||||
}
|
||||
|
||||
public static FrameworkElement CreateWorldImage(BitmapSource bitmap, WorldFileParameters parameters)
|
||||
{
|
||||
if (parameters.XScale == 0d || parameters.YScale == 0d)
|
||||
{
|
||||
throw new ArgumentException("Invalid WorldFileParameters, XScale and YScale must be non-zero.");
|
||||
}
|
||||
|
||||
var pixelWidth = parameters.XScale;
|
||||
var pixelHeight = parameters.YScale;
|
||||
var rotation = 0d;
|
||||
|
||||
if (parameters.YSkew != 0 || parameters.XSkew != 0)
|
||||
{
|
||||
pixelWidth = Math.Sqrt(parameters.XScale * parameters.XScale + parameters.YSkew * parameters.YSkew);
|
||||
pixelHeight = Math.Sqrt(parameters.YScale * parameters.YScale + parameters.XSkew * parameters.XSkew);
|
||||
|
||||
var xAxisRotation = Math.Atan2(parameters.YSkew, parameters.XScale) / Math.PI * 180d;
|
||||
var yAxisRotation = Math.Atan2(parameters.XSkew, -parameters.YScale) / Math.PI * 180d;
|
||||
rotation = 0.5 * (xAxisRotation + yAxisRotation);
|
||||
}
|
||||
|
||||
var x1 = parameters.XOrigin;
|
||||
var x2 = parameters.XOrigin + pixelWidth * bitmap.PixelWidth;
|
||||
var y1 = parameters.YOrigin;
|
||||
var y2 = parameters.YOrigin + pixelHeight * bitmap.PixelHeight;
|
||||
|
||||
var bbox = new BoundingBox
|
||||
{
|
||||
West = Math.Min(x1, x2),
|
||||
East = Math.Max(x1, x2),
|
||||
South = Math.Min(y1, y2),
|
||||
North = Math.Max(y1, y2)
|
||||
};
|
||||
|
||||
FrameworkElement image = new Image
|
||||
{
|
||||
Source = bitmap,
|
||||
Stretch = Stretch.Fill
|
||||
};
|
||||
|
||||
if (rotation != 0d)
|
||||
{
|
||||
image.RenderTransform = new RotateTransform { Angle = rotation };
|
||||
var panel = new Grid();
|
||||
panel.Children.Add(image);
|
||||
image = panel;
|
||||
}
|
||||
|
||||
MapPanel.SetBoundingBox(image, bbox);
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,12 +54,12 @@ namespace MapControl.Images
|
|||
YOrigin = yorigin;
|
||||
}
|
||||
|
||||
public double XScale { get; set; }
|
||||
public double YSkew { get; set; }
|
||||
public double XSkew { get; set; }
|
||||
public double YScale { get; set; }
|
||||
public double XOrigin { get; set; }
|
||||
public double YOrigin { get; set; }
|
||||
public double XScale { get; set; } // A
|
||||
public double YSkew { get; set; } // D
|
||||
public double XSkew { get; set; } // B
|
||||
public double YScale { get; set; } // E
|
||||
public double XOrigin { get; set; } // C
|
||||
public double YOrigin { get; set; } // F
|
||||
|
||||
public BoundingBox GetBoundingBox(double imageWidth, double imageHeight, MapProjection projection = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ namespace MapControl.Images
|
|||
public double MinZoomLevel { get; set; } = 0d;
|
||||
public double MaxZoomLevel { get; set; } = 22d;
|
||||
public double FadeZoomRange { get; set; } = 1d;
|
||||
public double MaxOpacity { get; set; } = 1d;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
|
|
@ -32,7 +33,7 @@ namespace MapControl.Images
|
|||
|
||||
if (zoomLevel > MinZoomLevel && zoomLevel < MaxZoomLevel)
|
||||
{
|
||||
opacity = 1d;
|
||||
opacity = MaxOpacity;
|
||||
|
||||
if (FadeZoomRange > 0d)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue