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?
How to combine two images
-
- Posts: 197
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
- BruceSteers
- Posts: 1608
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: How to combine two images
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?
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?
Paint.Begin(hSquarePic)
Paint.DrawPicture(hRoundPic, 0, 0, Paint.W, Paint.H)
Paint.End
If at first you don't succeed , try doing something differently.
BruceS
BruceS
-
- Posts: 197
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: How to combine two images
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
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
-
- Posts: 197
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: How to combine two images
Thanks Bruce, by 'merge' I mean the overlaying one image over the other.
- BruceSteers
- Posts: 1608
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: How to combine two images
Whatever works for you dude.
does it have to be an image that you read/overlay?
you could just draw it
does it have to be an image that you read/overlay?
you could just draw it
Dim p As Picture = New Picture(300, 300)
p.Image.Fill(Color.White) ' fill white background
Paint.Begin(p)
' draw a blue square with 10 px margin
Paint.FillRect(10, 10, 280, 280, Color.blue)
' draw a green circle, centered and radius 10px less than image size
Paint.Background = Color.green
Paint.Arc(150, 150, 140)
Paint.Fill()
Paint.End
If at first you don't succeed , try doing something differently.
BruceS
BruceS
-
- Posts: 197
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: How to combine two images
and Paint.DrawImage(hImageCircle, 0, 0, 112, 112)
works just fine.
Thanks again
works just fine.
Thanks again