Combine image (JPEG)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mihail
    Contributor
    • Apr 2011
    • 759

    Combine image (JPEG)

    Hello !

    I am trying to develop a video editor (VB6).
    For that I am looking for a way to combine 2 .jpeg pictures onto one file (also .jpeg).
    Note, please that this files have the same dimensions (width and height).
    And I need that one of them to be smaller than the other.

    So, my idea is to use 3 pictures boxes:
    Pic_1) with full size (JPEG dimensions).
    Pic_2) at a percent (say 20%) from the Pic_1.
    Pic_3) again at full size but as background the Pic_1 image and, in front of this image the image from Pic_2 placed at certain coordinates (relative to Pic_3 edges).

    Is it any way to create the image for Pic_3 ?

    To get a better idea: I try to show a movie in another movie.

    Thank you !
  • IraComm
    New Member
    • Oct 2012
    • 14

    #2
    Code:
    Picture1.Picture = LoadPicture(PictureFolder & "\" & a$)
        For h = 0 To Picture1.ScaleHeight Step Picture2.ScaleHeight
            For G = 0 To Picture1.ScaleWidth Step Picture2.ScaleWidth
            
                For x = 0 To Picture2.ScaleWidth - 7 Step iStep
                   DoEvents
                    For y = 0 To Picture2.ScaleHeight - 7 Step iStep
                        'get color
                      
                        
                            'HERE WE GET THE RGB VALUES OF THE FIRST PICTURE
                            z = Picture2.Point(x, y)
                                If z <> MaskColor Then
                                    'Debug.Print Picture2.Point(x, y); " ";
                                    GET_COLORS Picture1.Point(G + x, h + y), R1, G1, B1, False
                                    'HERE WE GET THE RGB VALUES OF THE SECOND PICTURE
                                    GET_COLORS Picture2.Point(x, y), R2, G2, B2, False
                                    
                                    'set insert to % of current color
                                    Percent = iOpaque / 100
                                    If R2 > R1 Then
                                        R3 = R1 + ((R2 - R1) * Percent)
                                    Else
                                        R3 = R1 - ((R1 - R2) * Percent)
                                    End If
                                    If G2 > G1 Then
                                        G3 = G1 + ((G2 - G1) * Percent)
                                    Else
                                        G3 = G1 - ((G1 - G2) * Percent)
                                    End If
                                    If B2 > B1 Then
                                        B3 = B1 + ((B2 - B1) * Percent)
                                    Else
                                        B3 = B1 - ((B1 - B2) * Percent)
                                    End If
                                    
                                    'WE PUT AN AVERAGE OF BOTH PIXELS IN THE THIRD PICTURE BOX
                                    'pset puts a pixel on a specified x,y point, with a RGB color.
                                   Picture1.PSet (G + x, h + y), RGB(R3, G3, B3)
                                End If
                                If bCancel Then
                                    bCancel = False
                                    Exit Sub
                                End If
                    Next y
                Next x
            Next
        Next

    Comment

    • Mihail
      Contributor
      • Apr 2011
      • 759

      #3
      Thank you for the answer, IraComm.
      I read your code (I don't try yet) and I think that is a point to start for me.

      Because my English I think I don't explain very well what I am looking for.

      I try to show the main movie in the main window and the second movie in a second window.
      Something like this:
      Code:
      ----------------------------------------
      |                                      |
      |                                      |
      |         Main Movie                   |
      |                                      |
      |    ---------------                   |
      |    |   Second    |                   |
      |    |   movie     |                   |
      |    |             |                   |
      |    ---------------                   |
      |                                      |
      |                                      |
      |                                      |
      |                                      |
      ----------------------------------------
      Initially I have the frames (as .jpg files) for both movies.
      The .jpg files have the same dimensions.

      The goal is to reduce the dimensions for the second frame (second .jpg file) then to put this "new" frame (.jpg) into the main frame (also .jpg) at certain coordinates.

      The main problem for me is to reduce the size for the second frame (.jpg). Without loosing quality, of corse.

      You give me a good idea to play with SCALE.
      Thank you, again. I'll try

      Comment

      Working...