private void fillSymbolList(List<Bitmap> imgList, Image<Bgr, Byte> srcImage)
{
FeatureInJSON _featureInJSON;
GeoJson geoJson = new GeoJson();
try
{
if (!File.Exists(_rasterInfo.rasterData + "\\PositiveLayerInfo.json"))
return;
_featureInJSON = geoJson.readGeoJsonFile(_rasterInfo.rasterData + "\\PositiveLayerInfo.json");
for (int j = 0; j < _featureInJSON.features.Count; j++)
{
double x1, x2, y1, y2;
Rectangle rec;
x1 = _featureInJSON.features[j].geometry.rings[0, 0, 0];
y1 = _featureInJSON.features[j].geometry.rings[0, 0, 1];
x2 = _featureInJSON.features[j].geometry.rings[0, 1, 0];
y2 = _featureInJSON.features[j].geometry.rings[0, 2, 1];
if (_rasterInfo.rasterType != "Unknown")
{
double pixelX1, pixelY1, pixelX2, pixelY2;
////////////////////geo Spatial Project Change/////////////////////
GetXY(x1, y1, out pixelX1, out pixelY1);
GetXY(x2, y2, out pixelX2, out pixelY2);
double r1 = pixelY2 - pixelY1;
double r2 = pixelX2 - pixelX1;
rec = new Rectangle((int.Parse(Math.Round(pixelX1).ToString())), int.Parse((Math.Round(pixelY1)).ToString()),
int.Parse(Math.Round(Math.Abs(r2)).ToString()), int.Parse(Math.Round(Math.Abs(r1)).ToString()));
}
else
{
rec = new Rectangle((int.Parse(Math.Round(Math.Abs(x1)).ToString())), int.Parse((Math.Round(Math.Abs(y1))).ToString()),
int.Parse(Math.Round(Math.Abs(x1 - x2)).ToString()), int.Parse(Math.Round(Math.Abs(y1 - y2)).ToString()));
}
// Image<Bgr, Byte> test = srcImage.GetSubRect(rec);
Bitmap img = srcImage.Bitmap;
Bitmap cropedImage = img.Clone(rec, img.PixelFormat);
if (!System.IO.Directory.Exists(_rasterInfo.rasterIn))
System.IO.Directory.CreateDirectory(_rasterInfo.rasterIn);
Bitmap resizedImage = new Bitmap(cropedImage, cropedImage.Width, cropedImage.Height);
resizedImage.Save(_rasterInfo.rasterIn + "\\element.png");
imgList.Add(cropedImage);
}
}
catch (Exception e)
{
Log.WriteLine("fillImageList: " + e.Message);
}
}