Mergin images

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arunbalait
    New Member
    • Feb 2007
    • 164

    Mergin images

    Hi to all


    Please give me code samples to merge two or more images into a single image using VB. Please send me immediately...

    Thanx
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    What do you mean merge images? Like picture of a dog to merge with a cat?
    How program should decide what part of the image goes where?

    Open paint and try to do it manually. It is tedious job even when you are looking at it.


    Use Photoshop instead of VB.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by arunbalait
      Please give me code samples to merge two or more images into a single image using VB. Please send me immediately...
      I think you need to be more specific about what you mean by "merge" in this context. Are you talking about morphing, or what?

      Comment

      • arunbalait
        New Member
        • Feb 2007
        • 164

        #4
        No not at all morphing....

        Merging in the sense combinig two or more pictures into a single one...



        If we are having more than one image files then after selecting those multiple images merging operation has to be done and the selected images would be saved as a single image...


        For eg, We having images like several animals as different pictures If we selected those pictures and merge then those pictures must be merged as a single one like the output having group of animals...


        Got it?

        Thanx...


        Is it possible?

        Comment

        • johnmartin
          New Member
          • Feb 2007
          • 2

          #5
          Originally posted by arunbalait
          No not at all morphing....

          Merging in the sense combinig two or more pictures into a single one...



          If we are having more than one image files then after selecting those multiple images merging operation has to be done and the selected images would be saved as a single image...


          For eg, We having images like several animals as different pictures If we selected those pictures and merge then those pictures must be merged as a single one like the output having group of animals...


          Got it?

          Thanx...


          Is it possible?

          Here is the code you should check out.
          I deserve no credit for this code, however it functions with the result I believe you are attempting to achieve.

          In Control properties, browse for Picture 1 and assign it to picSource.
          Now, browse for picture 2 and assign it to picDestination.

          With These Controls In the frmMain Module.

          barAmount (Slider)
          Label1,Label2,L abel3,Label4
          lblInfo
          picDestination
          picSource

          Code:
          '*****************************CODE IN FORM MODULE
          
          
          ' ********************************************
          ' ** Purpose: Alpha Blending Pictures
          ' ** Website : www.svenni.com
          ' ** Programmer : Sveinn R. Sigurdsson
          ' ** e-mail : depill2000@hotmail.com
          ' ********************************************
          Option Explicit
          
          ' API DECLARATION [ ALPHA BLEND FUNCTION ]
          Private Declare Function AlphaBlend Lib "msimg32" ( _
          ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _
          ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
          ByVal xSrc As Long, ByVal ySrc As Long, ByVal widthSrc As Long, _
          ByVal heightSrc As Long, ByVal blendFunct As Long) As Boolean
          
          ' API DECLARATIONS [ COPY MEMORY FUNCTION ]
          Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
          Destination As Any, Source As Any, ByVal Length As Long)
          
          ' TYPE STRUCTURES
          Private Type typeBlendProperties
              tBlendOp As Byte
              tBlendOptions As Byte
              tBlendAmount As Byte
              tAlphaType As Byte
          End Type
          
          Private Sub barAmount_Scroll()
              ' Procedure Scope Declarations
              Dim tProperties As typeBlendProperties
              Dim lngBlend As Long
                  ' Clear the destination picture
              picDestination.Cls
              tProperties.tBlendAmount = 255 - barAmount
              ' Call the 'CopyMemory' with the specified parameters
              CopyMemory lngBlend, tProperties, 4
              ' Blend the pictures together and show them at the specified
              ' location in the specified picture box.
              AlphaBlend picDestination.hDC, 0, 0, picSource.ScaleWidth, picSource.ScaleHeight, _
              picSource.hDC, 0, 0, picSource.ScaleWidth, picSource.ScaleHeight, lngBlend
              ' Refresh the picture box with the new image
              picDestination.Refresh
          End Sub
          Please resond if this is your intended goal or if an alternate goal is expected.
          Good luck.

          Comment

          • johnmartin
            New Member
            • Feb 2007
            • 2

            #6
            RE: My Last Reply : ALPHABLENDING

            It is obvious that some controls are not needed, however I did not wish to hack apart another developers code for the example. The labels are not required and with a common dialog and proper code you can easily change the application to the user to select images during runtime. The AlphaBlending API was apparently shipped with Win98 and allows the user to set transparency level of a picture.
            Good Luck, Again.

            Comment

            Working...