none
Merge 2 images RRS feed

  • Question

  • I am trying to merge 2 images and able to perform the activity. But always the 2nd image not sitting completely or some issues.

    Here is the code I have used.

    Dim Result, g, Name, Layer
    Set Result = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", 1920, 1080)  'My monitor resolution
    Set g = DotNetFactory.CreateInstance("System.Drawing.Graphics").FromImage(Result)
    
    Set Layer = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", "C:\1.png")
    g.DrawImage Layer, 0, 0, 600, 500
    
    Set Layer = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", "C:\2.png")
    g.DrawImage Layer, 0, 500, 600, 1100  
    
    Result.Save str & "3.png"

    Code is working without any errors but always some mismatch in x,y DPIs. Also I tried DrawImageUnScaled but no luck.

    Could anyone tell me what exactly I am doing wrong with DPI positions.

    • Moved by Bob Beauchemin Friday, May 8, 2015 7:39 PM Moved to an appropriate forum for best results
    Friday, May 8, 2015 7:26 PM

Answers

    • Marked as answer by Shanmugavel C Tuesday, May 12, 2015 2:29 PM
    Saturday, May 9, 2015 5:40 PM
  • Thanks all for the information. I got it worked.

    The only problem I am facing is passing the point locations. Could anyone tell me the details of point locations.

    My monitor resolution is 1920x1080.

    I have 2 images printed from this monitor. Just want to merge these 2 images one below one without any crop of each image.

    I tried with the thought of 1080/2=540

    Dim Result, g, Name, Layer1
    	Set Result = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", 1920, 1050)   '1920, 1050
    	Result.SetResolution 50, 45
    	Set g = DotNetFactory.CreateInstance("System.Drawing.Graphics").FromImage(Result)
    	
    	Set Layer1 = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", strPath & "1.png")
    	Set pt1 = DotNetFactory.CreateInstance("System.Drawing.Point", "System.Drawing", 0, 0)
    	g.DrawImage Layer1, pt1
    	
    	Set Layer2 = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", strPath & "2.png")
    	Set pt2 = DotNetFactory.CreateInstance("System.Drawing.Point", "System.Drawing", 0, 540)
    	g.DrawImageUnScaled Layer2, pt2
    	
    	Result.Save str & "3.png"
    I got the 3.png by combining both images. But the quality was dull and not able to see the image details like text present in the image by zooming. Any ideas to improve quality?


    Monday, May 11, 2015 7:39 PM

All replies

    • Proposed as answer by Khanna Gaurav Saturday, May 9, 2015 5:39 PM
    Saturday, May 9, 2015 4:40 PM
    • Marked as answer by Shanmugavel C Tuesday, May 12, 2015 2:29 PM
    Saturday, May 9, 2015 5:40 PM
  • Hello Shanmugavel C,

    It seems that you are using the VB6 as the develop language, however,  the current forum do not support Visual Basic 6, there are many third-party support sites that do. If you have a VB6-related question please visit these popular forums: 

    Or you could check these links provided by others to created a .NET based applicato to see if you could achieve what you want.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 11, 2015 5:21 AM
    Moderator
  • Thanks all for the information. I got it worked.

    The only problem I am facing is passing the point locations. Could anyone tell me the details of point locations.

    My monitor resolution is 1920x1080.

    I have 2 images printed from this monitor. Just want to merge these 2 images one below one without any crop of each image.

    I tried with the thought of 1080/2=540

    Dim Result, g, Name, Layer1
    	Set Result = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", 1920, 1050)   '1920, 1050
    	Result.SetResolution 50, 45
    	Set g = DotNetFactory.CreateInstance("System.Drawing.Graphics").FromImage(Result)
    	
    	Set Layer1 = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", strPath & "1.png")
    	Set pt1 = DotNetFactory.CreateInstance("System.Drawing.Point", "System.Drawing", 0, 0)
    	g.DrawImage Layer1, pt1
    	
    	Set Layer2 = DotNetFactory.CreateInstance("System.Drawing.Bitmap", "System.Drawing", strPath & "2.png")
    	Set pt2 = DotNetFactory.CreateInstance("System.Drawing.Point", "System.Drawing", 0, 540)
    	g.DrawImageUnScaled Layer2, pt2
    	
    	Result.Save str & "3.png"
    I got the 3.png by combining both images. But the quality was dull and not able to see the image details like text present in the image by zooming. Any ideas to improve quality?


    Monday, May 11, 2015 7:39 PM