?
Solved

Merge two pictures in VB.NET

Posted on 2003-04-01
3
Medium Priority
?
3,228 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:djcybex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 320 total points
ID: 8246099
This code will overlay 1 bmp over another
Bitmap Circle = (Bitmap)Image.FromFile(@"c:\circle.bmp");
 
     Bitmap MergedBMP = (Bitmap)Image.FromFile(@"c:\cross.bmp");
 
     Graphics g = Graphics.FromImage(Circle);
 
     MergedBMP.MakeTransparent(Color.White);
 
     g.DrawImage(MergedBMP,0,0);
 
     g.Dispose();
 

 
     pictureBox1.Image = Circle;
 
0
 
LVL 1

Author Comment

by:djcybex
ID: 8247136
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?
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 8247333
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
0

Featured Post

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question