- 'La fonction principale :
-
- Function AfficherImage(Image As DirectDrawSurface7, ddsd As DDSURFACEDESC2, X As Integer, Y As Integer, Cadre As RECT)
- Dim CadreImage As RECT
-
- 'Si le CadreAffichage=0 on prend l'écran comme cadre :
- If Cadre.Right = 0 And Cadre.Bottom = 0 Then
- Cadre.Right = Screen.Width / Screen.TwipsPerPixelX
- Cadre.Bottom = Screen.Height / Screen.TwipsPerPixelY
- End If
-
- 'Valeurs par défaut du cadre de l'image
- CadreImage.Right = ddsd.lWidth
- CadreImage.Bottom = ddsd.lHeight
-
- 'Le cadre de l'image ne doit pas dépasser le cadre d'affichage
- If X < Cadre.Left Then
- If X + ddsd.lWidth > 0 Then CadreImage.Left = Cadre.Left - X Else Exit Function
- End If
- If X + ddsd.lWidth > Cadre.Right Then
- If X < Cadre.Right Then CadreImage.Right = Cadre.Right - X Else Exit Function
- End If
- If Y < Cadre.Top Then
- If Y + ddsd.lHeight > 0 Then CadreImage.Top = Cadre.Top - Y Else Exit Function
- End If
- If Y + ddsd.lHeight > Cadre.Bottom Then
- If Y < Cadre.Bottom Then CadreImage.Bottom = Cadre.Bottom - Y Else Exit Function
- End If
-
- 'Dessiner l'image
- Backbuffer.BltFast Min(X, 0), Min(Y, 0), Image, CadreImage, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY
-
- End Function
'La fonction principale :
Function AfficherImage(Image As DirectDrawSurface7, ddsd As DDSURFACEDESC2, X As Integer, Y As Integer, Cadre As RECT)
Dim CadreImage As RECT
'Si le CadreAffichage=0 on prend l'écran comme cadre :
If Cadre.Right = 0 And Cadre.Bottom = 0 Then
Cadre.Right = Screen.Width / Screen.TwipsPerPixelX
Cadre.Bottom = Screen.Height / Screen.TwipsPerPixelY
End If
'Valeurs par défaut du cadre de l'image
CadreImage.Right = ddsd.lWidth
CadreImage.Bottom = ddsd.lHeight
'Le cadre de l'image ne doit pas dépasser le cadre d'affichage
If X < Cadre.Left Then
If X + ddsd.lWidth > 0 Then CadreImage.Left = Cadre.Left - X Else Exit Function
End If
If X + ddsd.lWidth > Cadre.Right Then
If X < Cadre.Right Then CadreImage.Right = Cadre.Right - X Else Exit Function
End If
If Y < Cadre.Top Then
If Y + ddsd.lHeight > 0 Then CadreImage.Top = Cadre.Top - Y Else Exit Function
End If
If Y + ddsd.lHeight > Cadre.Bottom Then
If Y < Cadre.Bottom Then CadreImage.Bottom = Cadre.Bottom - Y Else Exit Function
End If
'Dessiner l'image
Backbuffer.BltFast Min(X, 0), Min(Y, 0), Image, CadreImage, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY
End Function