I'm currently working on Tracking Object by Color on my WebCam, and i have it going so far but i want to add an option to draw multiple Objects. Until now it only Draws a Rectangle around the biggest Object.
BlobCounter blobcounter = new BlobCounter();
blobcounter.MinHeight = 100;
blobcounter.MinWidth = 100;
blobcounter.ObjectsOrder = ObjectsOrder.Size;
blobcounter.ProcessImage(grayImage);
Rectangle[] rects = blobcounter.GetObjectsRectangles();
if (checkBox1.Checked == false)
{
if (rects.Length > 0)
{
Rectangle objectRect1 = rects[0];
Graphics g = Graphics.FromImage(video);
using (Pen pen = new Pen(Color.LightGreen, 3))
{
g.DrawRectangle(pen, objectRect1);
PointF drawPoin = new PointF(objectRect1.X, objectRect1.Y);
int objectX = objectRect1.X + objectRect1.Width / 2 - video.Width / 2;
int objectY = video.Height / 2 - (objectRect1.Y + objectRect1.Height / 2);
PointF drawPoin2 = new PointF(objectRect1.X, objectRect1.Y + objectRect1.Height + 4);
String Blobinformation = "X= " + objectX.ToString() + " Y= " + objectY.ToString() + "\nSize=" + objectRect1.Width + ", " + objectRect1.Height;
g.DrawString(Blobinformation, new Font("Arial", 12), new SolidBrush(Color.LightSkyBlue), drawPoin2);
}
g.Dispose();
}
}
else
{
??????????
}
Adding a simple foreach loop should suffice. I don't know how efficient the drawing is, but I'm almost certain it wont be a problem with a few rectangles.
else
{
if (rects.Length > 0)
{
foreach (Rectangle objectRect in rects)
{
Graphics g = Graphics.FromImage(video);
using (Pen pen = new Pen(Color.LightGreen, 3))
{
g.DrawRectangle(pen, objectRect);
PointF drawPoin = new PointF(objectRect.X, objectRect.Y);
int objectX = objectRect.X + objectRect.Width / 2 - video.Width / 2;
int objectY = video.Height / 2 - (objectRect.Y + objectRect.Height / 2);
PointF drawPoin2 = new PointF(objectRect.X, objectRect.Y + objectRect.Height + 4);
String Blobinformation = "X= " + objectX.ToString() + " Y= " + objectY.ToString() + "\nSize=" + objectRect.Width + ", " + objectRect.Height;
g.DrawString(Blobinformation, new Font("Arial", 12), new SolidBrush(Color.LightSkyBlue), drawPoin2);
}
g.Dispose();
}
}
}
Related
I've been drawn multiple rectangles on the picturebox image.I want to resize all that rectangles using mouse events. Can anyone help me out regarding this?
public List<rectangle> listRec = new List<rectangle>();
Graphics g;
//private Graphics g;
Point startPos;
Point currentPos;
bool drawing;
Rectangle r1;
Rectangle rect = new Rectangle();
private Rectangle getRectangle()
{
r1 = new Rectangle(
Math.Min(startPos.X, currentPos.X),
Math.Min(startPos.Y, currentPos.Y),
Math.Abs(startPos.X - currentPos.X),
Math.Abs(startPos.Y - currentPos.Y));
return r1;
}
private void button1_Click(object sender, EventArgs e)
{
String data;
Font font = new Font("Arial", 14);
arg1 = Convert.ToInt32(textBox1.Text);
arg2 = Convert.ToInt32(textBox2.Text);
Rectangle rect = new Rectangle();
rect.Size = new Size(40, 65);
for (int x = 0; x < arg1; x++)
{
// rect.X = x * rect.Width;
rect.X = x * (rect.Width + 30) + 73;
for (int y = 0; y < arg2; y++)
{
rect.Y = y * (rect.Height + 35) + 38;
listRec.Add(rect);
data = rect.ToString();
TextWriter txt = new StreamWriter("E:\\B1Pockets.txt", true);
txt.WriteLine(data);
txt.Close();
// MessageBox.Show(rect.ToString());
}
}
foreach (Rectangle rec in listRec)
{
g = pictureBox1.CreateGraphics();
Pen p = new Pen(Color.Red, 3);
g.DrawRectangle(p, rec);
g.DrawString("p1", font, new SolidBrush(Color.Yellow), (rect.Width + 30), 35);
g.DrawString("p2", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 60, 35);
g.DrawString("p3", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 130, 35);
g.DrawString("p4", font, new SolidBrush(Color.Yellow), (rect.Width + 30), (rect.Height + 30) + 40);
g.DrawString("p5", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 60, (rect.Height + 30) + 40);
g.DrawString("p6", font, new SolidBrush(Color.Yellow), (rect.Width + 40) + 130, (rect.Height + 30) + 40);
}
}
I've tried this code to my application.I drawn rectangles in 2*3 manner.and also draw a big rectangle above it.In short my picturebox containing many rectangles and i want to add resizing options for all the rectangles in c#
I am developing a system just like Camera mouse or other face control mouse, I have implemented all the functionality, the mouse pointer is also moving well, but I want to create the movement smooth just like the mouse control the pointer. the code I am using is:
if (startButton == true)
{
try
{
cap = new Capture();
pictureBox1.Image = cap.QueryFrame().ToImage<Bgr, Byte>().Bitmap;
}
catch (Exception exp)
{
MessageBox.Show("Error:" + exp);
}
_cascadeClassifier = new CascadeClassifier(Application.StartupPath + "/haarcascade_frontalface_default.xml");
eye_cascadeClassifier = new CascadeClassifier(Application.StartupPath + "/haarcascade_eye.xml");
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
using (var imageFrame = cap.QueryFrame().ToImage<Bgr, Byte>().Flip(FlipType.Horizontal))
{
if (imageFrame != null)
{
var grayframe = imageFrame.Convert<Gray, byte>();
var faces = _cascadeClassifier.DetectMultiScale(grayframe, 1.1, 10, Size.Empty); //the actual face detection happens here
foreach (var face in faces)
{
if(Configure.FaceBoxCheck==true)
imageFrame.Draw(face, new Bgr(Color.LightGreen), 2); //the detected face(s) is highlighted here using a box that is drawn around it/them
Int32 yCoordStartSearchEyes = face.Top + (face.Height * 3 / 11);
Point startingPointSearchEyes = new Point(face.X, yCoordStartSearchEyes);
Size searchEyesAreaSize = new Size(face.Width, (face.Height * 3 / 11));
Rectangle possibleROI_eyes = new Rectangle(startingPointSearchEyes, searchEyesAreaSize);
int widthNav = (imageFrame.Width / 11 * 3);
int heightNav = (imageFrame.Height / 11 * 3);
Rectangle nav = new Rectangle(new Point(imageFrame.Width / 2 - widthNav / 2, imageFrame.Height / 2 - heightNav / 2), new Size(widthNav, heightNav));
imageFrame.Draw(nav, new Bgr(Color.Lavender), 3);
Point cursor = new Point(face.X + searchEyesAreaSize.Width / 2, yCoordStartSearchEyes + searchEyesAreaSize.Height / 2);
grayframe.ROI = possibleROI_eyes;
var eyes = eye_cascadeClassifier.DetectMultiScale(grayframe, 2.15, 3, Size.Empty);
foreach (var eye in eyes)
{
//imageFrame.Draw(eye, new Bgr(Color.Red), 2);
if(Configure.EyeBoxCheck==true)
imageFrame.Draw(possibleROI_eyes, new Bgr(Color.DarkGreen), 2);
if (nav.Left < cursor.X && cursor.X < (nav.Left + nav.Width) && nav.Top < cursor.Y && cursor.Y < nav.Top + nav.Height)
{
LineSegment2D CursorDraw = new LineSegment2D(cursor, new Point(cursor.X, cursor.Y + 1));
imageFrame.Draw(CursorDraw, new Bgr(Color.White), 3);
//we compute new cursor coordinate using a simple scale based on frame width and height
int xCoord = (imageFrame.Width * (cursor.X - nav.Left)) / nav.Width;
int yCoord = (imageFrame.Height * (cursor.Y - nav.Top)) / nav.Height;
//We set our new cursor position
Cursor.Position = new Point(xCoord * 2, yCoord *2);
}
}
}
Ok, I'm sure there are a lot of other better ways, but this is a quick&dirty way of moving cursor position in a "Smooth" way from point a to point b. Of course this implementation can and should be optimized using a different thread instead of using Application.DoEvents() to avoid blocking the UI thread, but i hope this gets you on the track. First, how you should use it. Instead of:
Cursor.Position = new Point(xCoord * 2, yCoord *2);
You should do this:
MoveCursorSmooth(Cursor.Position, new Point(xCoord * 2, yCoord *2));
Now, the implementation of MoveCursorSmooth:
private void MoveCursorSmooth(Point a, Point b)
{
var step = 5;
var left = Math.Min(a.X, b.X);
var right = Math.Max(a.X, b.X);
int width = right - left;
var top = a.Y;
var bottom = b.Y;
int height = bottom - top;
if (width > height)
{
double slope = (double)height / (double)width;
if (a.X <= b.X)
for (int x = 1; x < width; ++x)
{
Cursor.Position = new Point((left + x), (a.Y + ((int)(slope * x + 0.5))));
System.Threading.Thread.Sleep(step);
Application.DoEvents();
}
else
for (int x = 1; x < width; ++x) // xOffset
{
Cursor.Position = new Point((right - x), (a.Y + ((int)(slope * x + 0.5))));
System.Threading.Thread.Sleep(step);
Application.DoEvents();
}
}
else
{
double slope = (double)width / (double)height;
if (a.X <= b.X)
{
for (int y = 1; y < height; ++y)
{
Cursor.Position = new Point((a.X + ((int)(slope * y + 0.5))), (top + y));
System.Threading.Thread.Sleep(step);
Application.DoEvents();
}
}
else
{
for (int y = 1; y < height; ++y)
{
Cursor.Position = new Point((b.X + ((int)(slope * y + 0.5))), (bottom - y));
System.Threading.Thread.Sleep(step);
Application.DoEvents();
}
}
}
}
This method is based on this answer
I have a page that displays documents stored as Tiff images. Sometimes the image as displayed is not clear enough for the users to be certain they have the correct document. They need a zoom function.
The original code looks like this:
public void GetPage(int page)
{
var c = Request.Cookies["TiffViewer"];
string key = c["Key"];
if (Cache[key] != null)
{
using (MemoryStream ms = new MemoryStream((byte[])Cache[key]))
{
using (Bitmap img = new Bitmap(ms))
{
img.SelectActiveFrame(FrameDimension.Page, page);
using (Bitmap b = new Bitmap(img, new Size(img.Width / 2, img.Height / 2)))
{
using (Graphics gr = Graphics.FromImage(b))
{
var gray_matrix = new float[][] {
new float[] { 0.299f, 0.299f, 0.299f, 0, 0 },
new float[] { 0.587f, 0.587f, 0.587f, 0, 0 },
new float[] { 0.114f, 0.114f, 0.114f, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 0, 0, 0, 0, 1 }};
using (var ia = new ImageAttributes())
{
ia.SetColorMatrix(new ColorMatrix(gray_matrix));
ia.SetThreshold(0.8f, ColorAdjustType.Default);
gr.DrawImage(b, new Rectangle(0, 0, b.Width, b.Height), 0, 0, b.Width, b.Height, GraphicsUnit.Pixel, ia);
}
}
b.Save(Response.OutputStream, ImageFormat.Jpeg);
}
}
}
}
}
I have tried a number of different manipulations of the bitmap and drawimage. The closest I have come to getting a 'zoom' was by replacing the gr.DrawImage based on this article: http://stackoverflow.com/questions/2319983/resizing-an-image-in-asp-net-without-losing-the-image-quality
The replaced gr.DrawImage statement looks like:
gr.DrawImage(b, new Rectangle(0, 0, b.Width*2, b.Height*2), new Rectangle(0, 0, b.Width, b.Height), GraphicsUnit.Pixel);
This causes the text image to be much larger, but now only part of the image is visible. The area for the display of the image remains static. I either need to make the 'display area' larger, or somehow allow scrolling on the displayed image. Suggestions welcome.
I managed to come up with a solution that is not perfect, but allows users to get more details of the documents they're trying to see.
Two controls were added to the aspx page:
<div class="Controls">
<asp:Label ID="info" runat="server" Text=""></asp:Label>
<asp:Button ID="Return" runat="server" Text="Return" onclick="Return_Click" />
<asp:Button ID="Download" runat="server" Text="Download" onclick="Download_Click" />
<asp:Button ID="Stamp" runat="server" Text="Stamp" onclick="Stamp_Click" />
<asp:Button ID="Print" runat="server" Text="Print" onclick="Print_Click" />
<asp:Button ID="Zoom_In" runat="server" Text="-" onclick="ZoomIn_Click" />
<asp:Button ID="Zoom_Out" runat="server" Text="+" onclick="ZoomOut_Click" />
</div>
Also on the aspx page I modified the script that renders the tiff file to add the Size change percent:
<script type="text/javascript">
var html;
var cookie = c("TiffViewer");
var percent = '<%= Request.QueryString["ChangeSize"]%>';
var ImHeight = cookie["ImHeight"];
var ImWidth = cookie["ImWidth"];
for (var i = 1; i < +cookie["PageCount"] + 1; i++) {
$("#Pages").append("<a href='#page/" + (i - 1) + "'>" + i + "</a><br />");
if (ImHeight == 0 || ImWidth == 0) {
html = "<div class='slide' id='slide' overflow='scroll'><br /><b>Page {0}</b><br /><img id='p{1}' {2} /></div>";
$("#frames").append(String.format(html, i, i - 1, (i == (1) || i == (+cookie["PageCount"]) ? "src='Viewer.aspx?p=" + (i - 1) + "&" + "ChangeSize=" + percent + "'" : "")));
}
else {
var adjHeight = ImHeight / 2;
var adjWidth = ImWidth / 2;
html = "<div class='slide' id='slide' height='" + adjHeight.toString() + "'><br /><b>Page {0}</b><br /><img height='" + adjHeight.toString() + "' width='" + adjWidth.toString() + "' id='p{1}' {2} /></div>";
$("#frames").append(String.format(html, i, i - 1, (i == (1) || i == (+cookie["PageCount"]) ? "src='Viewer.aspx?p=" + (i - 1) + "&" + "ChangeSize=" + percent + "'" : "")));
}
}
</script>
On the code behind page I stored the values in cookies in the "using (var ia = new ImageAttributes())" section of code:
using (var ia = new ImageAttributes())
{
ia.SetColorMatrix(new ColorMatrix(gray_matrix));
ia.SetThreshold(0.8f, ColorAdjustType.Default);
//gr.DrawImage(b, new Rectangle(0, 0, (int)(b.Width * (1 + (percent / 100))), (int)(b.Height * (1 + (percent / 100)))), 0, 0, (int)(b.Width * (1 + (percent / 100))), (int)(b.Height * (1 + (percent / 100))), GraphicsUnit.Pixel, ia);
gr.DrawImage(b, new Rectangle(0, 0, (int)(b.Width * (1 + (percent / 100))), (int)(b.Height * (1 + (percent / 100)))), new Rectangle(0, 0, (int)(b.Width * (1 + (percent / 100))), (int)(b.Height * (1 + (percent / 100)))), GraphicsUnit.Pixel);
//gr.DrawImage(b, new Rectangle(0, 0, (int)(b.Width * (1 + (percent / 100))), (int)(b.Height * (1 + (percent / 100)))), new Rectangle(0, 0, b.Width, b.Height), GraphicsUnit.Pixel);
string myHeight;
string myWidth;
ImHeight = (int)(b.Height * (1 + (percent / 100)));
ImWidth = (int)(b.Width * (1 + (percent / 100)));
myHeight = ImHeight.ToString(); ;
myWidth = ImWidth.ToString(); ;
Response.Cookies["TiffViewer"]["ReturnURL"] = c["ReturnURL"];
Response.Cookies["TiffViewer"]["Key"] = c["Key"];
Response.Cookies["TiffViewer"]["ImHeight"] = myHeight;
Response.Cookies["TiffViewer"]["ImWidth"] = myWidth;
Response.Cookies["TiffViewer"]["PageCount"] = c["PageCount"];
}
For the two new controls I added the following click procedures:
protected void ZoomIn_Click(object sender, EventArgs e)
{
var c = Request.Cookies["TiffViewer"];
string key = c["Key"];
if (Cache[key] != null)
{
float chg = -10.0f;
float percent = 0.0f;
float.TryParse(Request.QueryString["ChangeSize"], out percent);
percent += chg;
int ImHeight = 0;
int.TryParse(c["ImHeight"], out ImHeight);
int ImWidth = 0;
int.TryParse(c["ImWidth"], out ImWidth);
string myHeight = "0";
string myWidth = "0";
if (ImHeight > 0 && ImWidth > 0)
{
ImHeight = (int)(ImHeight * (1 + (percent / 100)));
myHeight = ImHeight.ToString();
ImWidth = (int)(ImWidth * (1 + (percent / 100)));
myWidth = ImWidth.ToString();
}
Response.Cookies["TiffViewer"]["ReturnURL"] = c["ReturnURL"];
Response.Cookies["TiffViewer"]["Key"] = c["Key"];
Response.Cookies["TiffViewer"]["ImHeight"] = myHeight;
Response.Cookies["TiffViewer"]["ImWidth"] = myWidth;
Response.Cookies["TiffViewer"]["PageCount"] = c["PageCount"];
Response.Redirect("~/Viewer/Viewer.aspx?ChangeSize=" + percent.ToString());
}
}
protected void ZoomOut_Click(object sender, EventArgs e)
{
var c = Request.Cookies["TiffViewer"];
string key = c["Key"];
if (Cache[key] != null)
{
float chg = 10.0f;
float percent = 0.0f;
float.TryParse(Request.QueryString["ChangeSize"], out percent);
percent += chg;
int ImHeight = 0;
int.TryParse(c["ImHeight"], out ImHeight);
int ImWidth = 0;
int.TryParse(c["ImWidth"], out ImWidth);
string myHeight = "0";
string myWidth = "0";
if (ImHeight > 0 && ImWidth > 0)
{
ImHeight = (int)(ImHeight * (1 + (percent / 100)));
myHeight = ImHeight.ToString();
ImWidth = (int)(ImWidth * (1 + (percent / 100)));
myWidth = ImWidth.ToString();
}
Response.Cookies["TiffViewer"]["ReturnURL"] = c["ReturnURL"];
Response.Cookies["TiffViewer"]["Key"] = c["Key"];
Response.Cookies["TiffViewer"]["ImHeight"] = myHeight;
Response.Cookies["TiffViewer"]["ImWidth"] = myWidth;
Response.Cookies["TiffViewer"]["PageCount"] = c["PageCount"];
Response.Redirect("~/Viewer/Viewer.aspx?ChangeSize=" + percent.ToString());
}
}
Why is this code imperfect? In part because other parts of this code is designed to render the tiff the height of the window. So the tiff is never rendered taller, only wider by this code. So though this is inelegant it does let the users "zoom" to see the details of the documents better.
I can filter red and blue color separately but i want to filter both at the same time.. so my code is like this
//FOR RED COLOR
ColorFiltering filter = new ColorFiltering();
filter.Red = new IntRange(100, 255);
filter.Green = new IntRange(0, 75);
filter.Blue = new IntRange(0, 75);
filter.ApplyInPlace(image1);
MyDraw(image1);
// FOR BLUE COLOR
EuclideanColorFiltering filter2 = new EuclideanColorFiltering();
filter2.CenterColor = new RGB(Color.FromArgb(9, 39, 101));
filter2.Radius = 50;
filter2.ApplyInPlace(image1);
MyDraw(image1);
public void MyDraw(Bitmap image)
{
BlobCounter blobCounter = new BlobCounter();
blobCounter.MinWidth = 2;
blobCounter.MinHeight = 2;
blobCounter.FilterBlobs = true;
blobCounter.ObjectsOrder = ObjectsOrder.Size;
Grayscale grayFilter = new Grayscale(0.2125, 0.7154, 0.0721);
Bitmap grayImage = grayFilter.Apply(image);
blobCounter.ProcessImage(grayImage);
Rectangle[] rects = blobCounter.GetObjectsRectangles();
foreach (Rectangle recs in rects)
{
if (rects.Length > 0)
{
Rectangle objectRect = rects[0];
//Graphics g = Graphics.FromImage(image);
Graphics g = pictureBox1.CreateGraphics();
reception = "Cam," + objectRect.X + "," + objectRect.Y;
Console.WriteLine("X: " + objectRect.X + " Y:" + objectRect.Y.ToString());
using (Pen pen = new Pen(Color.FromArgb(252, 3, 26), 2))
{
g.DrawRectangle(pen, objectRect);
}
int objectX = objectRect.X + (objectRect.Width / 2);
int objectY = objectRect.Y + (objectRect.Height / 2);
g.DrawString(objectX.ToString() + "X" + objectY.ToString(), new Font("Arial", 12), Brushes.Red, new System.Drawing.Point(250, 1));
g.Dispose();
}
}
}
So i want to recognize blue and red shapes on webcam and draw a rectangle around recognized shape. For now, I can do it as red or blue. But I want to recognize red and blue colors at the same time
how can i add multiple filters?
I have two pictureboxes: One in the background with an image in it (picturebox1) and another one,(pic1) were i want to paint something (this background should be transparent.--> pic1.BackColor = Color.Transparent;)
It look like that:
Everything works great except the font. why does it have a black border?
My code looks like that:
private void InBitmapZeichnen()
{
Graphics g1 = Graphics.FromImage(bmp12);
g1.PageUnit = GraphicsUnit.Pixel;
//g1.InterpolationMode = InterpolationMode.HighQualityBilinear;
Font f = new Font("Verdana", 8f);
Font f1 = new Font("Verdana", 8f);
Font f2 = new Font("Verdana", 10, System.Drawing.FontStyle.Bold);
Brush b = new SolidBrush(Color.YellowGreen);
Brush b1 = new SolidBrush(Color.YellowGreen);
Pen PenRaster = new Pen(Color.Black, 0.1f);
if (mnuRaster.Checked == true)
{
float j = Rohrdurchmesser / (float)(trk.Value + 2);
//g1.SmoothingMode = SmoothingMode.HighSpeed;
for (int i = pic1.Width / (trk.Value + 2); i <= pic1.Width - pic1.Width / (trk.Value + 2); i += pic1.Width / (trk.Value + 2))
{
PointF PRaster1 = new PointF(i, 0);
PointF PRaster2 = new PointF(i, pic1.Bottom);
PointF PRaster3 = new PointF(0, i+4);
PointF PRaster4 = new PointF(pic1.Right, i+4);
g1.DrawString((j).ToString("0") + " mm", f, b, new PointF(i + 5, 5));
g1.DrawString((j).ToString("0") + " mm", f, b, new PointF(5, i + 5));
g1.DrawLine(PenRaster, PRaster1, PRaster2);
g1.DrawLine(PenRaster, PRaster3, PRaster4);
j += Rohrdurchmesser / (float)(trk.Value + 2);
}
}
}
When I select a color for backcolor it works fine:
Try use GraphicsPath if you want to draw text on trasparent background:
private void InBitmapZeichnen()
{
Graphics g1 = Graphics.FromImage(bmp12);
g1.PageUnit = GraphicsUnit.Pixel;
g1.SmoothingMode = SmoothingMode.AntiAlias;
//g1.InterpolationMode = InterpolationMode.HighQualityBilinear;
Font f = new Font("Verdana", 8f);
Font f1 = new Font("Verdana", 8f);
Font f2 = new Font("Verdana", 10, System.Drawing.FontStyle.Bold);
Brush b = new SolidBrush(Color.YellowGreen);
Brush b1 = new SolidBrush(Color.YellowGreen);
Pen PenRaster = new Pen(Color.Black, 0.1f);
if (mnuRaster.Checked == true)
{
float j = Rohrdurchmesser / (float)(trk.Value + 2);
//g1.SmoothingMode = SmoothingMode.HighSpeed;
for (int i = pic1.Width / (trk.Value + 2); i <= pic1.Width - pic1.Width / (trk.Value + 2); i += pic1.Width / (trk.Value + 2))
{
PointF PRaster1 = new PointF(i, 0);
PointF PRaster2 = new PointF(i, pic1.Bottom);
PointF PRaster3 = new PointF(0, i + 4);
PointF PRaster4 = new PointF(pic1.Right, i + 4);
using (var path = new GraphicsPath())
{
path.AddString((j).ToString("0") + " mm", f.FontFamily, (int)f.Style, f.Size, new Point(i + 5, 5), null);
path.AddString((j).ToString("0") + " mm", f.FontFamily, (int)f.Style, f.Size, new Point(5, i + 5), null);
g1.FillPath(b, path);
}
//g1.DrawString((j).ToString("0") + " mm", f, b, new PointF(i + 5, 5));
//g1.DrawString((j).ToString("0") + " mm", f, b, new PointF(5, i + 5));
g1.DrawLine(PenRaster, PRaster1, PRaster2);
g1.DrawLine(PenRaster, PRaster3, PRaster4);
j += Rohrdurchmesser / (float)(trk.Value + 2);
}
}
}
As you can see instead of DrawString i used FillPath.
I think need to clear Back Color before you start drawing on picture box.
Graphics g1 = Graphics.FromImage(bmp12);
// add clear
g1.Clear(BackColor);
So try this statement in your code...!!!