Bonjour.
Voila, comme l'explique brièvement le titre, j'ai un problème de transparence lorsque j'utilise une surface DirectX 7 obtenu par le hDC d'une picturebox.
premièrement, je récupère et atribut le hDC à la surface avec cette fonction : [code]Public Function BltToDD(ByVal hDC As Long, DDSurf As DirectDrawSurface7, ByVal PosX As Long, ByVal PosY As Long, Optional ByVal Width As Long, Optional ByVal Height As Long)
Dim DDhDC As Long, desc As DDSURFACEDESC2 'hDC for the Surface and description of surface
DDhDC = DDSurf.GetDC 'Get the surface DC
DDSurf.GetSurfaceDesc desc 'Get the description
'Blt the PicBox to the Surface and return the False if theres an error
If IsMissing(Height) Or Height <= 0 Then Height = desc.lHeight
If IsMissing(Width) Or Width <= 0 Then Width = desc.lWidth
BltToDD = (BitBlt(DDhDC, 0, 0, Width, Height, hDC, PosX, PosY, vbSrcCopy) = 0)
DDSurf.ReleaseDC DDhDC 'Release the DC
End Function[/code]
par la suite, je récupère le pixel du haut gauche qui est de la couleur de transparence et l'applique grâce à ce sub : [code]Public Sub SetMaskColorFromPixel(ByRef TheSurface As DirectDrawSurface7, ByVal X As Long, ByVal Y As Long)
Dim TmpR As RECT
Dim TmpDDSD As DDSURFACEDESC2
Dim TmpColorKey As DDCOLORKEY
With TmpR
.Left = X
.Top = Y
.Right = X
.Bottom = Y
End With
TheSurface.Lock TmpR, TmpDDSD, DDLOCK_WAIT Or DDLOCK_READONLY, 0
With TmpColorKey
.low = TheSurface.GetLockedPixel(X, Y)
.high = .low
If TheSurface Is DD_InfoSurf Then
.high = .low
End If
End With
TheSurface.SetColorKey DDCKEY_SRCBLT, TmpColorKey
TheSurface.Unlock TmpR
End Sub[/code]
je la Blt à la surface primaire, seulement la transparence n'y est pas.
À noter que la même démarche fonctionne si l'on remplace le hDC de la picture par un fichier Image, seulement je ne veux pas que ce soit un fichier Image ou un fichier Ressource.
Bonsoir et Merci.