By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,598 Members | 1,508 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,598 IT Pros & Developers. It's quick & easy.

Insert Border around a picture

P: n/a
I wonder if there is an easy way to plase a border around a picture.

I have already tryed with the trasparent function but the border gets upon
the picture so it hides some of it.

I have created borders with white space in the middle and with the
bmp_Frame.MakeTransparent(Color.White)

and
Dim pointToDraw As New RectangleF(0, 0, PictureBox1.Width, PictureBox1.Height)

gr.DrawImage(bmp_Frame, pointToDraw)

I create a new picture having on top the border.

What I want is to place it around.

regards

Aris Lazaridis

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
So what is happening when you create the new bitmap?

Seems you would create a new bitmap, bigger than the original, according to
border width, offset the top left corner accordingly, drawimage from
original to new one and then save/display it.

What's happening?

shane
"Aris" <Ar**@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
I wonder if there is an easy way to plase a border around a picture.

I have already tryed with the trasparent function but the border gets upon
the picture so it hides some of it.

I have created borders with white space in the middle and with the
bmp_Frame.MakeTransparent(Color.White)

and
Dim pointToDraw As New RectangleF(0, 0, PictureBox1.Width,
PictureBox1.Height)

gr.DrawImage(bmp_Frame, pointToDraw)

I create a new picture having on top the border.

What I want is to place it around.

regards

Aris Lazaridis

Nov 21 '05 #2

P: n/a
"Aris" <Ar**@discussions.microsoft.com> schrieb:
I wonder if there is an easy way to plase a border around a picture.


\\\
Dim b As Image = Bitmap.FromFile("C:\WINDOWS\Angler.bmp")
Me.PictureBox1.Image = CreateFramedImage(b, Color.Yellow, 2)
b.Dispose()
..
..
..
Private Function CreateFramedImage( _
ByVal Source As Image, _
ByVal BorderColor As Color, _
ByVal BorderThickness As Integer _
) As Image
Dim b As New Bitmap( _
Source.Width + BorderThickness * 2, _
Source.Height + BorderThickness * 2 _
)
Dim g As Graphics = Graphics.FromImage(b)
g.Clear(BorderColor)
g.DrawImage(Source, BorderThickness, BorderThickness)
g.Dispose()
Return b
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #3

P: n/a
Thanks for your answer but I know this much.
What I need is to figure out the dimentions of the inner white space of each
border ... if it is possible ?

You see I want to have predifined images as borders with drawings to put
around the pictures.

Thanks in advance
and thanks again for your tip.
"Herfried K. Wagner [MVP]" wrote:
"Aris" <Ar**@discussions.microsoft.com> schrieb:
I wonder if there is an easy way to plase a border around a picture.


\\\
Dim b As Image = Bitmap.FromFile("C:\WINDOWS\Angler.bmp")
Me.PictureBox1.Image = CreateFramedImage(b, Color.Yellow, 2)
b.Dispose()
..
..
..
Private Function CreateFramedImage( _
ByVal Source As Image, _
ByVal BorderColor As Color, _
ByVal BorderThickness As Integer _
) As Image
Dim b As New Bitmap( _
Source.Width + BorderThickness * 2, _
Source.Height + BorderThickness * 2 _
)
Dim g As Graphics = Graphics.FromImage(b)
g.Clear(BorderColor)
g.DrawImage(Source, BorderThickness, BorderThickness)
g.Dispose()
Return b
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

P: n/a
Thanks for your time but..

I dont know exactly what will be the border thikness.
I want to calculate somehow the inner white space or some other color to
create inside of it the new image (picture)

Regards
Aris
"Shane Story" wrote:
So what is happening when you create the new bitmap?

Seems you would create a new bitmap, bigger than the original, according to
border width, offset the top left corner accordingly, drawimage from
original to new one and then save/display it.

What's happening?

shane
"Aris" <Ar**@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
I wonder if there is an easy way to plase a border around a picture.

I have already tryed with the trasparent function but the border gets upon
the picture so it hides some of it.

I have created borders with white space in the middle and with the
bmp_Frame.MakeTransparent(Color.White)

and
Dim pointToDraw As New RectangleF(0, 0, PictureBox1.Width,
PictureBox1.Height)

gr.DrawImage(bmp_Frame, pointToDraw)

I create a new picture having on top the border.

What I want is to place it around.

regards

Aris Lazaridis


Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.