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! 5 2022
* "Sjaakie Helderhorst" <di*********@hotNOTmail.com> scripsit: 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.HighQualityBic ubic
' 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 [MVP]
<URL:http://dotnet.mvps.org/>
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:2j*************@uni-berlin.de... * "Sjaakie Helderhorst" <di*********@hotNOTmail.com> scripsit: 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.HighQualityBic ubic
' 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 [MVP] <URL:http://dotnet.mvps.org/>
Didn't know it was that easy :)
Thanks!
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:2j*************@uni-berlin.de... * "Sjaakie Helderhorst" <di*********@hotNOTmail.com> scripsit: 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.HighQualityBic ubic
' 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" <di*********@hotNOTmail.com> scripsit: 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 [MVP]
<URL:http://dotnet.mvps.org/>
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:2j*************@uni-berlin.de... * "Sjaakie Helderhorst" <di*********@hotNOTmail.com> scripsit: 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 [MVP] <URL:http://dotnet.mvps.org/>
Lol, never mind, I'd never got this far without your help, thanks again! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Mlynarczyk |
last post by:
Hi,
I'm looking for a way to put a 1px solid border around the image in this
link:
<a href="some.html"><img src="some.gif"></a>
Well, that, by itself, is simple. However, I would like to have a...
|
by: Michael Winter |
last post by:
I have the familiar 'thumbnail' scenario. I want to place a small
border around the image when the cursor hovers above it. I use a 1
pixel, solid border around the image that changes between normal...
|
by: Applebrown |
last post by:
Hello, basically, I'm just learning intermediate CSS and trying to convert
my old table webpage completely to CSS. Hoorah, right? Well, it's not quite
going as planned. It's an extremely simple...
|
by: Oliver |
last post by:
Hello i want to get a nice border around images, but not just with the
simple <img src"....." border="1"> tag.
I tried it in CSS.
I did the following:
<div class="img_class">
<img...
|
by: Bob Bedford |
last post by:
I've an image in a cell of a table.
I've this CSS:
..dbtable{
width: 600px;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
border-collapse: collapse;
border: 1px solid #000000;
|
by: Dino Buljubasic |
last post by:
Hi,
I have several panels that holds bunch of controls with information on
my forms. My form has background image property set to an image that
has borders defining where my panel comes and...
|
by: deko |
last post by:
I'm trying to get a 1px border around the content section of this page:
http://www.clearpointsystems.com
As you will see, I have a header/nav bar (looks correct), but the border around
the...
|
by: bmjnine |
last post by:
Hi all,
I am converting image files of various formats to JPEG using:
System.Drawing.Image img = System.Drawing.Image.FromFile(myfilepath);
Works great except that transparent GIF's are over...
|
by: PunchBackJack |
last post by:
Im having trouble getting this site to show correctly in IE (big surprise). I have a div element (side bar) inside another div element that simply takes the size of the largest element inside as the...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |