White border around resized image

  • Thread starter Thread starter Sjaakie Helderhorst
  • Start date Start date
S

Sjaakie Helderhorst

Hi all,
I wrote a simple .net app which resizes all images in a directory to a
preset imagesize. I want to take this a step further and add a 10px white
border around the image. I can't figure out how to achieve this ... can
someone tell me how to resize the canvas-size and not the entire image...

Thanks in advance!
 
* "Sjaakie Helderhorst said:
I wrote a simple .net app which resizes all images in a directory to a
preset imagesize. I want to take this a step further and add a 10px white
border around the image. I can't figure out how to achieve this ... can
someone tell me how to resize the canvas-size and not the entire image...

\\\
Dim bmp As New Bitmap( _
"C:\Lagoon1024x768.bmp" _
)
Dim bmp2 As New Bitmap( _
bmp.Width * 0.1 + 20, _
bmp.Height * 0.1 + 20, _
Imaging.PixelFormat.Format24bppRgb _
)
Dim g As Graphics = Graphics.FromImage(bmp2)

g.Clear(Color.White)

' Select/change interpolation mode here.
g.InterpolationMode = _
Drawing.Drawing2D.InterpolationMode.HighQualityBicubic

' Draw image using specified interpolation mode.
g.DrawImage(bmp, 10, 10, bmp2.Width, bmp2.Height)
g.Dispose()

Me.PictureBox1.Image = bmp2
bmp2.Save("C:\foo.bmp")
..
..
..
///
 
Herfried K. Wagner said:
image...

\\\
Dim bmp As New Bitmap( _
"C:\Lagoon1024x768.bmp" _
)
Dim bmp2 As New Bitmap( _
bmp.Width * 0.1 + 20, _
bmp.Height * 0.1 + 20, _
Imaging.PixelFormat.Format24bppRgb _
)
Dim g As Graphics = Graphics.FromImage(bmp2)

g.Clear(Color.White)

' Select/change interpolation mode here.
g.InterpolationMode = _
Drawing.Drawing2D.InterpolationMode.HighQualityBicubic

' Draw image using specified interpolation mode.
g.DrawImage(bmp, 10, 10, bmp2.Width, bmp2.Height)
g.Dispose()

Me.PictureBox1.Image = bmp2
bmp2.Save("C:\foo.bmp")
.
.
.
///

Didn't know it was that easy :)
Thanks!
 
Herfried K. Wagner said:
image...

\\\
Dim bmp As New Bitmap( _
"C:\Lagoon1024x768.bmp" _
)
Dim bmp2 As New Bitmap( _
bmp.Width * 0.1 + 20, _
bmp.Height * 0.1 + 20, _
Imaging.PixelFormat.Format24bppRgb _
)
Dim g As Graphics = Graphics.FromImage(bmp2)

g.Clear(Color.White)

' Select/change interpolation mode here.
g.InterpolationMode = _
Drawing.Drawing2D.InterpolationMode.HighQualityBicubic

' Draw image using specified interpolation mode.
g.DrawImage(bmp, 10, 10, bmp2.Width, bmp2.Height)
g.Dispose()

Me.PictureBox1.Image = bmp2
bmp2.Save("C:\foo.bmp")
.

NOTE: g.DrawImage(bmp, 10, 10, bmp2.Width, bmp2.Height) should be replaced
by g.DrawImage(bmp, 10, 10) or it will end up with borders at only left and
top...
 
* "Sjaakie Helderhorst said:
NOTE: g.DrawImage(bmp, 10, 10, bmp2.Width, bmp2.Height) should be replaced
by g.DrawImage(bmp, 10, 10) or it will end up with borders at only left and
top...

OK, I didn't test the code before posting it ;-).
 
Herfried K. Wagner said:
OK, I didn't test the code before posting it ;-).

Lol, never mind, I'd never got this far without your help, thanks again!
 
Back
Top