|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.EngineEditor.Common
|
|
|
|
|
{
|
|
|
|
|
public class ImgDistinguish
|
|
|
|
|
{
|
|
|
|
|
public TilesImage GetImg(IEnvelope pEnvelope)
|
|
|
|
|
{
|
|
|
|
|
TilesImage result = new TilesImage();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<ILayer> layers = null;// Env.Instance.KMap.GetAllKOTilesLayer();//有待还原
|
|
|
|
|
if (layers == null)
|
|
|
|
|
return null;
|
|
|
|
|
List<TilesImage> listImg = new List<TilesImage>();
|
|
|
|
|
foreach (KOTilesLayer layer in layers)
|
|
|
|
|
{
|
|
|
|
|
TilesImage img = layer.GetImage(pEnvelope);
|
|
|
|
|
if (img == null)
|
|
|
|
|
continue;
|
|
|
|
|
listImg.Add(img);
|
|
|
|
|
}
|
|
|
|
|
if (listImg.Count == 0)
|
|
|
|
|
return result;
|
|
|
|
|
if (listImg.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
result = listImg[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(listImg[0].Img);
|
|
|
|
|
//合并图片
|
|
|
|
|
for (int i = 1; i < listImg.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
bmp = CombinImage(bmp, listImg[i].Img);
|
|
|
|
|
}
|
|
|
|
|
result = listImg[0];
|
|
|
|
|
result.Img = bmp;
|
|
|
|
|
//bmp.Save("D://6.png");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("获取Img信息 时异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("获取Img信息 时异常信息结束");
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 合并图片
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="imgBack"></param>
|
|
|
|
|
/// <param name="img"></param>
|
|
|
|
|
/// <param name="xDeviation"></param>
|
|
|
|
|
/// <param name="yDeviation"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public Bitmap CombinImage(Image imgBack, Image img, int xDeviation = 0, int yDeviation = 0)
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(imgBack.Width, imgBack.Height);
|
|
|
|
|
Graphics g = Graphics.FromImage(bmp);
|
|
|
|
|
g.Clear(Color.Transparent);
|
|
|
|
|
g.DrawImage(imgBack, 0, 0, imgBack.Width, imgBack.Height);
|
|
|
|
|
g.DrawImage(img, imgBack.Width / 2 - img.Width / 2 + xDeviation, imgBack.Height / 2 - img.Height / 2 + yDeviation, img.Width, img.Height);
|
|
|
|
|
GC.Collect();
|
|
|
|
|
return bmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|