Bonsoir à tous,
j'ai un fichier "preview.jpg" verrouillé, alors que il me semble avoir fait ce qu'il fallait dans mon code.
Auriez vous une idée s'il vous plait, car je sèche complètement.
Le code est un tantinet compliqué mais ça permet d'afficher un logo en Overlay.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  Private Sub AfficheSkinAndLogo(Folder As String, SkinName As String)
        Dim PathBackImage As String = Folder & "\skins\" & SkinName & "\preview.jpg"
        Dim PathOverlayImage As String = Folder & "\ui\" & "badge.png"
 
        'Dim g As Graphics = Graphics.FromHwnd(pbCar2.Handle)
        'g.DrawImage(img, pbCar2.ClientRectangle)
        Dim BackImage As Bitmap = Nothing
        Dim OverLayImage As Bitmap = Nothing
 
        Try
            BackImage = New Bitmap(PathBackImage, True)
        Catch ex As Exception
 
        End Try
        Try
            OverLayImage = New Bitmap(PathOverlayImage, True)
        Catch ex As Exception
 
        End Try
        Dim BadgeSize As Single = 0.25
        Dim BadgePosX As Single = 0.05
        Dim BadgePosY As Single = 0.1
        If OverLayImage IsNot Nothing AndAlso BackImage IsNot Nothing Then
            Dim RatioImg As Single = CSng(OverLayImage.Width / OverLayImage.Height)
            Dim g As Graphics = Graphics.FromImage(BackImage)
            Dim Larg As Integer = BackImage.Width
            Dim Haut As Integer = CInt(Larg / RatioImg)
            If Haut > BackImage.Height Then
                Haut = CInt(BackImage.Height * BadgeSize)
                Larg = CInt(Haut * RatioImg)
            Else
                Larg = CInt(BackImage.Width * BadgeSize)
                Haut = CInt(Larg / RatioImg)
            End If
            Dim PosX As Integer = CInt((BackImage.Width - Larg) * BadgePosX)
            Dim PosY As Integer = CInt((BackImage.Height - Haut) * BadgePosY)
            g.DrawImage(OverLayImage, PosX, PosY, Larg, Haut)
        End If
 
        If BackImage IsNot Nothing Then
            Dim BackImageCache As New Bitmap(BackImage)
            BackImage.Dispose()
            BackImage = Nothing
            pbCar.Image = BackImageCache
        Else
            pbCar.Image = My.Resources.splash
        End If
        If OverLayImage IsNot Nothing Then
            OverLayImage.Dispose()
            OverLayImage = Nothing
        End If
    End Sub