P
Paul
Hi,
I am having trouble getting my VB app to join images on top of each
other to form a single file.
All my images are the same width and height and I would like to join
them together, one of top of the other.
My code compiles but does not give the right result!
Dim jpg1 As String = "c:\existing_image_1.jpg"
Dim jpg2 As String = "c:\existing_image_2.jpg"
Dim jpg3 As String = "c:\new_image.jpg"
Dim img1 As Image = Image.FromFile(jpg1)
Dim img2 As Image = Image.FromFile(jpg2)
Dim width As Integer = Math.Max(img1.Width, img2.Width)
Dim height As Integer = img1.Height + img2.Height + 20
Dim img3 As New Bitmap(width, height)
'MsgBox(img3.Width & " width, " & img3.Height & " height ")
Dim g As Graphics = Graphics.FromImage(img3)
g.Clear(Color.Empty)
g.DrawImage(img1, New Point(0, 0))
g.DrawImage(img1, New Point(0, img1.Height))
g.Dispose()
img1.Dispose()
img2.Dispose()
img3.Save(jpg3, System.Drawing.Imaging.ImageFormat.Jpeg)
img3.Dispose()
Its showing it like this.. Please excuse the crude diagram!
_________________________
| 1st image | |
| displays | |
|__here _____| |
| |
| |
| black background |
| |
| |
|____________ |
| 2nd image | |
|displays here | |
|___________ |_____________|
This is how I would like to to appear...
____________________
| |
| 1st image |
| here |
| |
| |
|___________________|
| |
| |
| 2nd image |
| here |
| |
|___________________|
Any help is much appreciated.
Thanks
Paul
I am having trouble getting my VB app to join images on top of each
other to form a single file.
All my images are the same width and height and I would like to join
them together, one of top of the other.
My code compiles but does not give the right result!
Dim jpg1 As String = "c:\existing_image_1.jpg"
Dim jpg2 As String = "c:\existing_image_2.jpg"
Dim jpg3 As String = "c:\new_image.jpg"
Dim img1 As Image = Image.FromFile(jpg1)
Dim img2 As Image = Image.FromFile(jpg2)
Dim width As Integer = Math.Max(img1.Width, img2.Width)
Dim height As Integer = img1.Height + img2.Height + 20
Dim img3 As New Bitmap(width, height)
'MsgBox(img3.Width & " width, " & img3.Height & " height ")
Dim g As Graphics = Graphics.FromImage(img3)
g.Clear(Color.Empty)
g.DrawImage(img1, New Point(0, 0))
g.DrawImage(img1, New Point(0, img1.Height))
g.Dispose()
img1.Dispose()
img2.Dispose()
img3.Save(jpg3, System.Drawing.Imaging.ImageFormat.Jpeg)
img3.Dispose()
Its showing it like this.. Please excuse the crude diagram!
_________________________
| 1st image | |
| displays | |
|__here _____| |
| |
| |
| black background |
| |
| |
|____________ |
| 2nd image | |
|displays here | |
|___________ |_____________|
This is how I would like to to appear...
____________________
| |
| 1st image |
| here |
| |
| |
|___________________|
| |
| |
| 2nd image |
| here |
| |
|___________________|
Any help is much appreciated.
Thanks
Paul