Link to home
Start Free TrialLog in
Avatar of djcybex
djcybexFlag for Slovenia

asked on

Merge two pictures in VB.NET

I have three pictureboxes. How to combine two pictures from two pictureboxes to third one...so that first picture is behind the second?
I need to save the third (combined) picture in database... (i know how to do this)

Thank you in advance.
Matej
ASKER CERTIFIED SOLUTION
Avatar of iboutchkine
iboutchkine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djcybex

ASKER

Thank you!

can you please suggest how to center the front picture to the one in the back?

i know you can set cordinates in
g.DrawImage(MergedBMP,x,y);

but pictures are diferent sizes...
and also DrawImage makes picture smaller than original..why is that?
Avatar of iboutchkine
iboutchkine

Try either to resize image

Private Sub ResizeImage()
     Dim filename As String = "C:\windows\web\wallpaper\wind.jpg"
     Dim photo As System.Drawing.Bitmap = New System.Drawing.Bitmap(filename)
     
     'Resize to medium
     Dim w As Integer = 200
     Dim h As Integer = 200
     
     Dim medium As New System.Drawing.Bitmap(w, h)
     Dim mG As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(medium)
     
     mG.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed
     mG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bicubic
     mG.DrawImage(photo, 0, 0, w, h)
     
     'Save
     medium.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg)
     medium.Dispose()
     photo.Dispose()
 
End Sub


or stretch it to the picbox size
 picImage.SizeMode = PictureBoxSizeMode.StretchImage