French Remplir une forme avec un bitmap

legugusse

Member
Licensed User
Longtime User
Bonjour,

existe-t-il un moyen de remplir une forme géométrique simple avec le contenu d'un bitmap? De texturer en quelque sorte.

Merci d'avance pour vos réponse.

LGG
 

klaus

Expert
Licensed User
Longtime User
Oui, ci-dessous un code exemple utilisant Canvas.ClipPath:
B4X:
Sub Globals
    Dim Canvas1 As Canvas
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim Path1 As Path
    Dim bmpTest As Bitmap
    Dim DestRect As Rect
    
    bmpTest.Initialize(File.DirAssets, "Rose1.jpg")
    Canvas1.Initialize(Activity)
    DestRect.Initialize(0, 0, 100%x, 100%y)
    
    Path1.Initialize(50%x, 100%y)
    Path1.LineTo(100%x, 50%y)
    Path1.LineTo(50%x, 0%y)
    Path1.LineTo(0%x, 50%y)
    Path1.LineTo(50%x, 100%y)
    Canvas1.ClipPath(Path1) 'clip the drawing area to the path.
    
    Canvas1.DrawBitmap(bmpTest, Null, DestRect) 'fill the drawing area with the gradient.

    Activity.Invalidate
End Sub
Meilleures salutations.
 

Attachments

  • DrawPathBitmap.jpg
    DrawPathBitmap.jpg
    53.4 KB · Views: 268
Last edited:
Top