Results 1 to 16 of 16

Thread: Stitching pictures

  1. #1

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Stitching pictures

    I have an application which requires me to stitch Google Earth maps together in a type of shifting map process and zoom them to various zoom factors.
    My users wil click on an area or point of interest and I need to use the point clicked and the zoom level required to compile a new consolidated map to conform to those requirements.
    In another thread Olaf has made very useful contributions using VBrichclient to do that, but I also wish to explore the possibilities of the .PaintPicture function.
    In fact I wish to write a general routine which will do all these things to present any map with any zoomfactor, depending on the need of the user.
    It can be compared to Russian dolls where every drill down exposes another doll in more detail and splendour.

    PK

  2. #2
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Stitching pictures

    This requires quick access to maps. And at the same time, 8 cards must be loaded: a working one and 7 adjacent along the edges, so that there is no delay when moving.
    The PintPicture method will do just fine.
    If there is an exit outside the working map, then a part of the adjacent one is copied to the vacant space.

  3. #3

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Stitching pictures

    Argus,
    Thanks, I will try that. The mistake I made was trying to load it directly into my destination picture with LoadPicture.
    PK

  4. #4
    Lively Member
    Join Date
    Mar 2015
    Posts
    104

    Re: Stitching pictures

    Does anyone have a small demo. I wanted to stitch up some bladed graphics (up to say 6 files) together like shown below (the one below is only 2 bmp files). I was wondering how to do it say selecting the files and by dragging a mouse and lastly saving. I have seen some examples that were on PlanetVb ages ago to make a montage, but perhaps there is a better way of doing it?


    Name:  stitched.jpg
Views: 232
Size:  27.5 KB

  5. #5

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Stitching pictures

    Creatrive dreamer,

    I know of the PaintPicture function which can stitch multiple pictures together in a looped routine programmatically at runtime, but it should not be very difficult to adapt it to take user input during runtime.

    I would do this:
    Make a main picturebox and set its scale to define its edges.
    Make a few other picturevboxes which will remain invisible and load the pictures which you wish to use as tiles into that. Also specify its scalemode parameters.
    Do a looped routine in which you ask the user which picture he/she wants to place where into the main picture box
    Save it to your disk.

    PK

  6. #6
    Lively Member
    Join Date
    Mar 2015
    Posts
    104

    Re: Stitching pictures

    Thanks Peekay for you quick response. I will experiment with your ideas.

  7. #7
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Stitching pictures

    Quote Originally Posted by CreativeDreamer View Post
    Does anyone have a small demo.
    I wrote a program for adding images horizontally and vertically. And saving in .bmp format.

    https://drive.google.com/file/d/171p...ew?usp=sharing

  8. #8

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Stitching pictures

    Argus19,
    I cannot read the filename or file of picture1 in the project code. Do you have a picture included?
    It says this is the filename: App.Path & "\Ïðèðîäà2.jpg"

    PK

  9. #9
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Stitching pictures

    Quote Originally Posted by Peekay View Post
    App.Path & "\Ïðèðîäà2.jpg"
    Just change the name of the .jpg file in the folder and project to English.
    Or load any graphic file into the project folder and insert its name into the given line.

  10. #10
    Lively Member
    Join Date
    Mar 2015
    Posts
    104

    Re: Stitching pictures

    Wow thankyou Argus19 for uploading the demo stitching program.

    I initially did not see your reply and then today I ended up coming across it. I will hopefully learn from it, as I tend to focus on making geometric lined patterns using my maths skills. I came across some advanced "Autostiching" projects using Accord on Codeproject but these are using other languages. I also came across examples that split a picture into equal sized sections, which is the reverse of what I wanted to do. I just needed to know the basics of joining pictures together. Thanks once again for your example.

  11. #11
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Stitching pictures

    Quote Originally Posted by CreativeDreamer View Post
    I just needed to know the basics of joining pictures together.
    The example uses the PaintPicture function. It can not only copy the image to certain coordinates, but also copy with scaling. You can modify the example so that both images to be merged are the same size. As you can see from the example, when you combine images of different sizes, a piece of an empty field remains.
    In the example, the second image is smaller than the first. If you copy it with scaling (proportional increase), then there will be no empty field.
    Name:  test.bmp
Views: 158
Size:  243.2 KB
    Last edited by Argus19; Apr 11th, 2021 at 01:25 AM.

  12. #12
    Lively Member
    Join Date
    Mar 2015
    Posts
    104

    Re: Stitching pictures

    I also wanted to mirror and do a horizontal/vertical flip and then combine 4 of the same pic (like below).

    Name:  mirrored.jpg
Views: 171
Size:  17.2 KB


    I will experiment a bit. I've seen api examples that flip and mirror but need to understand them better as my api knowledge is limited.

  13. #13
    Hyperactive Member
    Join Date
    Jul 2020
    Posts
    370

    Re: Stitching pictures

    For the given example.
    For the second image.
    Horizontally.
    Copy:
    Code:
    Picture3.PaintPicture Picture2.Picture, Width1, 0, Width2, Height2, 0, 0, Width2, Height2, vbSrcCopy
    Reverse copy:
    Code:
    Picture3.PaintPicture Picture2.Picture, Width1 * 2, 0, -Width1, Height1, 0, 0, Width2, Height2, vbSrcCopy
    Vertically:
    Copy:
    Code:
    Picture3.PaintPicture Picture2.Picture, 0, Height1, Width2, Height2, 0, 0, Width2, Height2, vbSrcCopy
    Reverse copy:
    Code:
    Picture3.PaintPicture Picture2.Picture, 0, Height1 + Height2, Width2, -Height2, 0, 0, Width2, Height2, vbSrcCopy

  14. #14

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Stitching pictures

    Argus19,

    Thanks for your profound contribution here. I can use it well.

    PK

  15. #15
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,253

    Re: Stitching pictures

    Quote Originally Posted by CreativeDreamer View Post
    I also wanted to mirror and do a horizontal/vertical flip and then combine 4 of the same pic (like below).

    Name:  mirrored.jpg
Views: 171
Size:  17.2 KB
    For those interested - here's how the RC6-cairo-wrapper can handle that reflection-task:

    Code:
    Option Explicit
    
    Private CC As cCairoContext '<- CC is the Context of the Form-covering Backing-Surface
    Private Img As cCairoSurface '<- Img will hold a little 64x64 Icon (loaded from shell32), provides the "TopLeft"-image of the 4xReflect 
    
    Private Sub Form_Load()
      Caption = "Resize Me"
      Set Img = Cairo.ImageList.AddIconFromResourceFile("ImgKey", "shell32", 167) 'load the resource-image
    End Sub
    
    Private Sub Form_Resize()
      ScaleMode = vbPixels
      Set CC = Cairo.CreateSurface(ScaleWidth, ScaleHeight).CreateContext 'ensure a Backing-context in the same size as the Form
      Redraw 'let's trigger a "scene-refresh" in our freshly created BackBuffer
    End Sub
    
    Private Sub Redraw()
      CC.Paint 1, Cairo.CreateCheckerPattern 'erase the BackGround with a checker-pattern
      
      Dim R4Srf As cCairoSurface 'let's create a separate ImgSrf which takes up the reflections
      Set R4Srf = Cairo.CreateSurface(Img.Width * 2, Img.Height * 2)
          R4Srf.CreateContext.Paint 1, Img.CreateSurfacePattern(CAIRO_FILTER_GOOD, CAIRO_EXTEND_REFLECT)
      
      'Ok, what we do now, is to render the new (area-wise 4 times as large as Img) R4Srf centered on the CC.Surface
      CC.RenderSurfaceContent R4Srf, (CC.Surface.Width - R4Srf.Width) / 2, (CC.Surface.Height - R4Srf.Height) / 2
     
      Set Picture = CC.Surface.Picture 'reflect the updated CC.Surface-content in the Form-Picture
    End Sub
    Here the output of this example (which renders the Result centered on the Form, no matter which Form-size)



    Olaf

  16. #16

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Stitching pictures

    Excellent thanks Olaf!

    PK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width