How to combine two images

Post

Posted
Rating:
#1 (In Topic #1212)
Regular
bill-lancaster is in the usergroup ‘Regular’
 I have two images, square.png and circle.png, both the same size and are black & white.
How can I merge them so that that are both shown in a new image?
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
please describe "merge"

should they be next to each other or one on top of the other.

do they have transparent backgrounds?

Can you not just use Paint.classs to paint one image on the other?

Code (gambas)

  1.  
  2. Paint.Begin(hSquarePic)
  3. Paint.DrawPicture(hRoundPic, 0, 0, Paint.W, Paint.H)
  4. Paint.End
  5.  
  6.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
bill-lancaster is in the usergroup ‘Regular’
 This does it!
  For x = 0 To hImageSquare.W - 1
    For y = 0 To hImageSquare.H - 1
      If hImageSquare[x, y] <> -16777216 Then hImageNew[x, y] = hImageSquare[x, y]
      If hImageCircle[x, y] <> -16777216 Then hImageNew[x, y] = hImageCircle[x, y]
    Next
  Next

The value 16777216 is the colour of the background.  16777215 = White
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
bill-lancaster is in the usergroup ‘Regular’
 Thanks Bruce, by 'merge' I mean the overlaying one image over the other.
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’
Whatever works for you dude.

does it have to be an image that you read/overlay?
you could just draw it

Code (gambas)

  1.  
  2. Dim p As Picture = New Picture(300, 300)
  3. p.Image.Fill(Color.White) ' fill white background
  4.  
  5. Paint.Begin(p)
  6.  
  7. '  draw a blue square with 10 px margin
  8. Paint.FillRect(10, 10, 280, 280, Color.blue)
  9.  
  10. ' draw a green circle, centered and radius 10px less than image size
  11. Paint.Background = Color.green
  12. Paint.Arc(150, 150, 140)
  13. Paint.Fill()
  14. Paint.End
  15.  
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
bill-lancaster is in the usergroup ‘Regular’
 and   Paint.DrawImage(hImageCircle, 0, 0, 112, 112)
 works just fine.
Thanks again
Online now: No Back to the top
1 guest and 0 members have just viewed this.