6 Replies - 655 Views - Last Post: 01 May 2012 - 03:28 PM Rate Topic: -----

#1 Confuzed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-April 12

Overlaying images help

Posted 26 April 2012 - 11:59 PM

So basically, I have an image that needs to be overlayed onto a second image on a form.
Here's the catch: the second image needs to be user defined( everyone I ask says merge them in photoshop)
How would I do this?(I've only been coding about a month)
Any help is appreciated
Is This A Good Question/Topic? 0
  • +

Replies To: Overlaying images help

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,060
  • Joined: 02-July 08

Re: Overlaying images help

Posted 27 April 2012 - 06:54 AM

You can do this with GDI+ and draw images on top of each other. In a paint event for the control your drawing the image to - use the e.Graphics.DrawImage method. If the second image does not have any transparency you will not see the first image.
Was This Post Helpful? 0
  • +
  • -

#3 Confuzed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-April 12

Re: Overlaying images help

Posted 27 April 2012 - 12:03 PM

View Post_HAWK_, on 27 April 2012 - 06:54 AM, said:

You can do this with GDI+ and draw images on top of each other. In a paint event for the control your drawing the image to - use the e.Graphics.DrawImage method. If the second image does not have any transparency you will not see the first image.

So the underlying image needs transparency as well?
Was This Post Helpful? 0
  • +
  • -

#4 ACParson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 17-February 10

Re: Overlaying images help

Posted 27 April 2012 - 12:29 PM

View PostConfuzed, on 27 April 2012 - 12:03 PM, said:

View Post_HAWK_, on 27 April 2012 - 06:54 AM, said:

You can do this with GDI+ and draw images on top of each other. In a paint event for the control your drawing the image to - use the e.Graphics.DrawImage method. If the second image does not have any transparency you will not see the first image.

So the underlying image needs transparency as well?


No, only the image you will draw on top of the underlying one needs transparency. What I think he means is, if the image specified by the user has no transparency, you will not see the underlying image.
Was This Post Helpful? 0
  • +
  • -

#5 Confuzed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-April 12

Re: Overlaying images help

Posted 27 April 2012 - 12:59 PM

Can you guys give me a sample on how to use this method?
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,060
  • Joined: 02-July 08

Re: Overlaying images help

Posted 27 April 2012 - 02:20 PM

You need some idea of your needs before you build the graphics part. Are you needing only 2 images or more than 2? If it is the first, you can set the first image as the BackgroundImage for a picturebox and then in the picturebox's paint event you simply draw that other image that the user selects onto the picturebox, like:

Private myImages As New List(Of Image)'collection/array

Private Sub pb_Paint(sender As Object, e As PaintEventArgs) Handles pb.Paint
   'if you only have a second image draw it to the 
   'picturebox's rectangle dimensions
  e.Graphics.DrawImage(<image>, pb.ClientRectangle)
   'or loop thru a collection
  For Each img As Image In myImages
     e.Graphics.DrawImage(img, pb.ClientRectangle)
  Next
End Sub

Was This Post Helpful? 0
  • +
  • -

#7 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: Overlaying images help

Posted 01 May 2012 - 03:28 PM

You can use code similar to watermarking images. You can draw a bitmap on top of the other and if you have set the tranparency to an amount lower than 255, you will see the image underneath.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1