We have an app written in C++ 6 that fills in blank polygons on a traffic map to show current traffic conditions. Green for good, yellow more congested, etc.
The "shell maps" are bitmaps of the roadways using rectangles and polygons that have nothing filled in them. Data is collected from roadway sensors (wire inductor loops) and the polygons are filled based on loop detector data.
When the maps change, someone has to manually zoom in the bitmap in paint, and get the coordinates around the inside of each new shape, where the congestion color will be filled in. The polygons that make the map skeleton are all drawn in navy blue, on a white background.
I made an app. where when the user clicks anywhere inside the white part of the polygon, the points for the inside perimeter are displayed to the user, with a zoomed in thumbnail showing the inside permiter painted.
In .Net, the perimeter is painted perfectly.
In the C++ 6 app, some of the polyon points my app. collects don't display correctly.
I looked at msPaint, and .Net does not draw the points the same way as MS Paint.
Here's a quick example. Code is from one form with one button and one label. A line is drawn on a bitmap, the bitmap is "zoomed in" so you can see it, and displayed on the label.
The line segment drawn is not the same as the line segment that you draw in MS Paint if you draw a line in Paint using the same two points.
private void button1_Click(object sender, EventArgs e)
{
Bitmap bm = new Bitmap(16, 16);
Graphics g = Graphics.FromImage(bm);
//g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
//g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
//g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed;
//g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Default;
Point pt = new Point(1, 3);
Point pt2 = new Point(5, 1);
// If you reverse the points, the same line is drawn.
g.DrawLine(Pens.Orange, pt, pt2);
// label1.Image = bm;
Bitmap bm2 = ZoomMap(8, bm);
g.Dispose();
bm.Dispose();
label1.Image = bm2;
}
private Bitmap ZoomMap(int zoomValue, Bitmap bm)
{
Bitmap zoomedBitMap;
Size sz = bm.Size;// new Size(75, 75);
Size newSize = new Size(sz.Width * zoomValue, sz.Height * zoomValue);
zoomedBitMap = new Bitmap(newSize.Width, newSize.Height);
Graphics gr = Graphics.FromImage(zoomedBitMap);
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
gr.PageUnit = GraphicsUnit.Pixel;
gr.DrawImage(bm, 1, 1, newSize.Width, newSize.Height);
gr.Dispose();
return zoomedBitMap;
}
No matter what settings I apply, there is no way to mimic MS Paint in C#, but in C++ 6 mimics MS Paint perfectly.
Is there any type of windows API I can call to draw on an existing bitmap?
Thanks in advance for any replies.