Проблемы с графикой
PHP эту картинку нарисовал вот так,
а asp вот так.
точки по которым велась отрисовка одни и теже, но в аспе 1на область на другую не попадает. какие то апроксимации мне непонятные. кто знает как это решить?
вот код:
Код:
string ConnectionString = SqlDataSource1.ConnectionString;
SqlConnection con = new SqlConnection(ConnectionString);
int CurrentWidth = 450;//(int)Math.Round(450 * MapScale, 1);
int CurrentHegiht = 500;//(int)Math.Round(500 * MapScale, 1);
Bitmap image = new Bitmap(CurrentHegiht, CurrentWidth);
Graphics g = Graphics.FromImage(image);
g.FillRectangle(Brushes.White, 0, 0, CurrentHegiht, CurrentWidth);
//g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawLine(Pens.Red, 0, 0, 5, 5);
Font font = new Font("Impact", 20, FontStyle.Regular);
con.Open();
char[] delimiterChars = {','};
String Sql = "SELECT reg_name, coords FROM dbo.reg WHERE okrug_id = '_cfo'";
SqlCommand cmd = new SqlCommand(Sql, con);
SqlDataReader reader = cmd.ExecuteReader();
StringBuilder htmlString = new StringBuilder("");
while (reader.Read())
{
string CurrentCoordsString = reader["coords"].ToString();
string[] arrayCoords = CurrentCoordsString.Split(delimiterChars);
int[] IntCurrentCoords = new int[arrayCoords.Length];
for (int a = 0; a<arrayCoords.Length-1; a++)
{
IntCurrentCoords[a] = Convert.ToInt32(arrayCoords[a]);
}
Point[] CurvePoints = new Point[IntCurrentCoords.Length/2-1];
int b = 0;
for (int i = 2; i < (IntCurrentCoords.Length-1); i = i+2)
{
Point TempPoint = new Point(IntCurrentCoords, IntCurrentCoords[i-1]);
CurvePoints = TempPoint;
b++;
}
g.FillPolygon(Brushes.Aqua, CurvePoints);
}
reader.Close();
SqlDataReader reader1 = cmd.ExecuteReader();
while (reader1.Read())
{
string CurrentCoordsString = reader1["coords"].ToString();
string[] arrayCoords = CurrentCoordsString.Split(delimiterChars);
int[] IntCurrentCoords = new int[arrayCoords.Length];
for (int a = 0; a < arrayCoords.Length - 1; a++)
{
IntCurrentCoords[a] = Convert.ToInt32(arrayCoords[a]);
}
Point[] CurvePoints = new Point[IntCurrentCoords.Length / 2 - 1];
int b = 0;
for (int i = 2; i < (IntCurrentCoords.Length - 1); i = i + 2)
{
Point TempPoint = new Point(IntCurrentCoords, IntCurrentCoords[i - 1]);
CurvePoints = TempPoint;
b++;
}
g.DrawLines(Pens.Black, CurvePoints);
}
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
reader1.Close();
g.Dispose();
image.Dispose();
con.Close();
// Создаем новое соединение с ConnectionString
SqlConnection con = new SqlConnection(ConnectionString);
int CurrentWidth = 450;//(int)Math.Round(450 * MapScale, 1);
int CurrentHegiht = 500;//(int)Math.Round(500 * MapScale, 1);
Bitmap image = new Bitmap(CurrentHegiht, CurrentWidth);
Graphics g = Graphics.FromImage(image);
g.FillRectangle(Brushes.White, 0, 0, CurrentHegiht, CurrentWidth);
//g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawLine(Pens.Red, 0, 0, 5, 5);
Font font = new Font("Impact", 20, FontStyle.Regular);
con.Open();
char[] delimiterChars = {','};
String Sql = "SELECT reg_name, coords FROM dbo.reg WHERE okrug_id = '_cfo'";
SqlCommand cmd = new SqlCommand(Sql, con);
SqlDataReader reader = cmd.ExecuteReader();
StringBuilder htmlString = new StringBuilder("");
while (reader.Read())
{
string CurrentCoordsString = reader["coords"].ToString();
string[] arrayCoords = CurrentCoordsString.Split(delimiterChars);
int[] IntCurrentCoords = new int[arrayCoords.Length];
for (int a = 0; a<arrayCoords.Length-1; a++)
{
IntCurrentCoords[a] = Convert.ToInt32(arrayCoords[a]);
}
Point[] CurvePoints = new Point[IntCurrentCoords.Length/2-1];
int b = 0;
for (int i = 2; i < (IntCurrentCoords.Length-1); i = i+2)
{
Point TempPoint = new Point(IntCurrentCoords, IntCurrentCoords[i-1]);
CurvePoints = TempPoint;
b++;
}
g.FillPolygon(Brushes.Aqua, CurvePoints);
}
reader.Close();
SqlDataReader reader1 = cmd.ExecuteReader();
while (reader1.Read())
{
string CurrentCoordsString = reader1["coords"].ToString();
string[] arrayCoords = CurrentCoordsString.Split(delimiterChars);
int[] IntCurrentCoords = new int[arrayCoords.Length];
for (int a = 0; a < arrayCoords.Length - 1; a++)
{
IntCurrentCoords[a] = Convert.ToInt32(arrayCoords[a]);
}
Point[] CurvePoints = new Point[IntCurrentCoords.Length / 2 - 1];
int b = 0;
for (int i = 2; i < (IntCurrentCoords.Length - 1); i = i + 2)
{
Point TempPoint = new Point(IntCurrentCoords, IntCurrentCoords[i - 1]);
CurvePoints = TempPoint;
b++;
}
g.DrawLines(Pens.Black, CurvePoints);
}
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
reader1.Close();
g.Dispose();
image.Dispose();
con.Close();
// Создаем новое соединение с ConnectionString