how draw border on round image png?
-
hi all, can anybody help me to draw a thick border around round png.
Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
int w = bmp.Width;
int h = bmp.Height;
Lst_Data lastpointcolor = new Lst_Data() ;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
Color c = bmp.GetPixel(x, y);
if (c.A != Color.Transparent.A)
{
if (lastpointcolor.color.A == Color.Transparent.A)
{
bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
}
}
lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
}
}for (int y = h-1; y > 0; y--) { for (int x = w-1; x > 0; x--) { Color c = bmp.GetPixel(x, y); if (c.A != Color.Transparent.A) { if (lastpointcolor.color.A == Color.Transparent.A) { bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red); } } lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) }; } } pictureBox1.Image = bmp; }
public struct Lst_Data
{
public Point point;
public Color color;
}thanks in advance.
-
hi all, can anybody help me to draw a thick border around round png.
Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
int w = bmp.Width;
int h = bmp.Height;
Lst_Data lastpointcolor = new Lst_Data() ;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
Color c = bmp.GetPixel(x, y);
if (c.A != Color.Transparent.A)
{
if (lastpointcolor.color.A == Color.Transparent.A)
{
bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
}
}
lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
}
}for (int y = h-1; y > 0; y--) { for (int x = w-1; x > 0; x--) { Color c = bmp.GetPixel(x, y); if (c.A != Color.Transparent.A) { if (lastpointcolor.color.A == Color.Transparent.A) { bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red); } } lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) }; } } pictureBox1.Image = bmp; }
public struct Lst_Data
{
public Point point;
public Color color;
}thanks in advance.
What technology are you using? WinForms? WPF? Other?
-
What technology are you using? WinForms? WPF? Other?
-
winform i m taking help from this article https://stackoverflow.com/questions/15858002/drawing-a-border-on-an-image[^] i also want to set different width of border.
-
Le@rner wrote:
i m taking help from this article
Then you should ask the person who wrote the article. As it stands you have not provided any useful information for people to help you.
Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
int w = bmp.Width;
int h = bmp.Height;
Lst_Data lastpointcolor = new Lst_Data() ;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
Color c = bmp.GetPixel(x, y);
if (c.A != Color.Transparent.A)
{
if (lastpointcolor.color.A == Color.Transparent.A)
{
bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
}
}
lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
}
}for (int y = h-1; y > 0; y--) { for (int x = w-1; x > 0; x--) { Color c = bmp.GetPixel(x, y); if (c.A != Color.Transparent.A) { if (lastpointcolor.color.A == Color.Transparent.A) { bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red); } } lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) }; } } pictureBox1.Image = bmp; }
public struct Lst_Data
{
public Point point;
public Color color;
}can anybody help to draw more thick border around the image
-
Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
int w = bmp.Width;
int h = bmp.Height;
Lst_Data lastpointcolor = new Lst_Data() ;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
Color c = bmp.GetPixel(x, y);
if (c.A != Color.Transparent.A)
{
if (lastpointcolor.color.A == Color.Transparent.A)
{
bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
}
}
lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
}
}for (int y = h-1; y > 0; y--) { for (int x = w-1; x > 0; x--) { Color c = bmp.GetPixel(x, y); if (c.A != Color.Transparent.A) { if (lastpointcolor.color.A == Color.Transparent.A) { bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red); } } lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) }; } } pictureBox1.Image = bmp; }
public struct Lst_Data
{
public Point point;
public Color color;
}can anybody help to draw more thick border around the image
-
hi all, can anybody help me to draw a thick border around round png.
Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
int w = bmp.Width;
int h = bmp.Height;
Lst_Data lastpointcolor = new Lst_Data() ;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
Color c = bmp.GetPixel(x, y);
if (c.A != Color.Transparent.A)
{
if (lastpointcolor.color.A == Color.Transparent.A)
{
bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
}
}
lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
}
}for (int y = h-1; y > 0; y--) { for (int x = w-1; x > 0; x--) { Color c = bmp.GetPixel(x, y); if (c.A != Color.Transparent.A) { if (lastpointcolor.color.A == Color.Transparent.A) { bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red); } } lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) }; } } pictureBox1.Image = bmp; }
public struct Lst_Data
{
public Point point;
public Color color;
}thanks in advance.
You draw an ellipse and place it "over" the image where the border would be. (Images aren't "round"; they're rectangles with transparent backgrounds that simulate a particular shape). [Graphics.DrawEllipse Method (System.Drawing) | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.graphics.drawellipse?view=dotnet-plat-ext-6.0)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I