Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm looking for source code in VB.NET on how to concatenate two bitmaps together, top and bottom.

 

I've tried using the BitBlt function but can't quite seem to get it.

 

Thanks in advance,

Ben

Posted

       Dim Image1 As New Bitmap("c:\test.bmp")
       Dim Image2 As New Bitmap("c:\test.bmp")

       Dim Image3 As New Bitmap(600, 1000)
       Dim g As Graphics = Graphics.FromImage(Image3)
       g.DrawImage(Image1, New Point(0, 0))
       g.DrawImage(Image2, New Point(0, 500))
       g.Dispose()
       g = Nothing

       PictureBox1.Image = Image3

 

This will open a bitmap file that just happens to be 300x500 and load it into Image1 & Image2, image3 then Combines the two images into one big 600x1000 and displays it in a picturebox

 

Hope that helps

 

Andy

Code today gone tomorrow!
  • Leaders
Posted

Depending on your needs, you might want to turn it into a function.

 

Function JoinImagesVert(Image1 As Bitmap, Image2 As Bitmap) As Bitmap
   Dim Result As New Bitmap(Math.Max(Image1.Width, Image2.Width), _
       Image1.Height + Image2.Height)
   Dim gResult As Graphics = Graphics.FromImage(Resi;t)
   gResult.DrawImage(Image1, New Point(0, 0))
   gResult.DrawImage(Image2, New Point(0, Image1.Height))
   gResult.Dispose()
   gResult = Nothing

   Return Result

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...