Buonasera a tutti, ho un dubbio amletico pertanto ho bisogno del vostro aiuto. il pratica ciò che vorrei realizzare è un Sw che da 2 immagini mi crei una terza immagine che sia un merge delle 2... Ovvero ho 3 picturebox
Una imm. in picture1 un'altra in picture2 e poi cliccando un tasto vorrei che in picture3 mi compaiano le 2 immagini mixate.Diciamo che fin qui non ho avuto molti problemi usando questo codice:
Option Explicit
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal y As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal y As Long, ByVal crColor As Long) As Long
Dim r, g, b As Integer
Dim r2, g2, b2 As Integer
Dim percent As Integer
Dim Col As Long
Private Function rtnColorSplit(color1 As OLE_COLOR, color2 As OLE_COLOR) As OLE_COLOR
On Error Resume Next
r = color1 Mod 256
b = Int(color1 / 65536)
g = (color1 - (b * 65536) - r) / 256
r2 = color2 Mod 256
b2 = Int(color2 / 65536)
g2 = (color2 - (b2 * 65536) - r2) / 256
percent = 85
r = r + ((r2 - r) * (percent / 100))
g = g + ((g2 - g) * (percent / 100))
b = b + ((b2 - b) * (percent / 100))
rtnColorSplit = RGB(r, g, b)
End Function
Private Sub Command1_Click()
Dim X As Long
Dim y As Long
If Picture1.Width > Picture2.Width Then
Picture3.Width = Picture1.Width
Else
Picture3.Width = Picture2.Width
End If
If Picture1.Height > Picture2.Height Then
Picture3.Height = Picture1.Height
Else
Picture3.Height = Picture2.Height
End If
Picture1.Width = Picture3.Width
Picture2.Width = Picture3.Width
Picture1.Height = Picture3.Height
Picture2.Height = Picture3.Height
Picture3.Left = Picture1.Left + (Picture1.Width / 2) + 60
Picture3.Visible = True
For y = 0 To Picture3.ScaleWidth
For X = 0 To Picture3.ScaleHeight
SetPixelV Picture3.hdc, X, y, rtnColorSplit(GetPixel(Picture1.hdc, X, y), GetPixel(Picture2.hdc, X, y))
DoEvents
Next X
Next y
Command1.Caption = "true"
End Sub
Private Sub Command2_Click()
SavePicture Picture3.Image, "esempio.jpg"
End Sub
Private Sub Form_Load()
Picture1.ScaleMode = vbPixels
Picture2.Picture = LoadPicture("prova.jpg")
Picture1.Picture = LoadPicture("logoprova.jpg")
End Sub
Il problema sta nel fatto che io la foto della picture3 la dovrei salvare così com'è sul mio hd. Ovviamente la funzione savepicture non funziona... Ci sono per caso altre soluzioni?? Anche a costo di dover scegliere un'altra strada??