I am using PictureFillSymbol to display a photo on Map.
The Envelope is created based on the Map scale. And which works fine in the UI for zoom in and out.
If I print it won't work. then I converted Envelope to polygon and tried printing which works. howevere it is not scalling the image.
BitmapImage Bmp = sender as BitmapImage;
if (Bmp != null)
{
//use is pixel dimensions to calculate scale
double ImgWidth = Bmp.PixelWidth;
double ImgHeight = Bmp.PixelHeight;
if (Map.Extent.Width > 0 && Map.Extent.Height > 0) //stop div by zero
{
//calculate a scale to make the image 1/10th of map (at current zoom level)
double scale = ImgWidth / (Map.Extent.Width * 0.1);
scale = Math.Max(scale, ImgHeight / (Map.Extent.Height * 0.1));
if (scale > 0)//stop div by zero
{
MapPoint photoMapPointA = InsertionPoint;
MapPoint photoMapPointB = new MapPoint((photoMapPointA.X + ImgWidth / scale), (photoMapPointA.Y - ImgHeight / scale));
Envelope photoEnvelope = new Envelope(photoMapPointA, photoMapPointB);
ESRI.ArcGIS.Client.Geometry.Polygon p=new ESRI.ArcGIS.Client.Geometry.Polygon();
ESRI.ArcGIS.Client.Geometry.PointCollection pc = new ESRI.ArcGIS.Client.Geometry.PointCollection();
pc.Add(new MapPoint(photoEnvelope.XMin, photoEnvelope.YMin));
pc.Add(new MapPoint(photoEnvelope.XMin, photoEnvelope.YMax));
pc.Add(new MapPoint(photoEnvelope.XMax, photoEnvelope.YMax));
pc.Add(new MapPoint(photoEnvelope.XMax, photoEnvelope.YMin));
pc.Add(new MapPoint(photoEnvelope.XMin, photoEnvelope.YMin));
p.Rings = new ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection>();
p.Rings.Add(pc);
Graphic g = new Graphic();
g.Geometry = p;// photoEnvelope;
PictureFillSymbol pfs = new PictureFillSymbol();
pfs.Source = Bmp;
g.Symbol = pfs;
(Map.Layers[3] as GraphicsLayer).Graphics.Add(g);
}
}
}