| 12
 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
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 
 | <%@ Page Language="VB" Debug="true"%>
<%@ import namespace="System.Drawing" %>
<html>
    <head>
        <title></title>
    </head>
    <body>
        <script language="VB" runat="server">
 
            Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
                Dessineimage()                                      ' creer ou ecrase le fichier photo_rendu.jpg
                photo.ImageUrl = "photo_rendu.jpg"                  ' on associe la photo au controle	
 
 
 
            End Sub
 
            Sub Dessineimage()
 
                'on charge une image avec l'image d'origine
                Dim newImage As Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("mug.png"))
 
                'on crée cette image
                Dim mB As New Bitmap(newImage)
 
                'on crée le graphics
                Dim g As Graphics = Graphics.FromImage(mB)
 
                ' meilleur qualité possible du graphique
                g.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
 
                'on charge une nouvelle image qui sera devant l'autre
                Dim newImage2 As Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("flocons.png"))
 
                'on dessine l'image2 chargé ou l'on veut dans le graphique
                ' voici la syntaxe minimale donné par le SDK 
                'Overloads Public Sub DrawImage( _
                '   ByVal image As Image, _
                '   ByVal point As Point _
                ')
                g.DrawImage(newImage2, 80, 90)
 
                'on va faire un petit rectangle noir sur la photo
                'voici la syntaxe minimale donné par le SDK 
                'Overloads Public Sub FillRectangle( _
                '   ByVal pen As Pen, _
                '   ByVal x As Integer, _
                '   ByVal y As Integer, _
                '   ByVal width As Integer, _
                '   ByVal height As Integer _
                ')
                ' Create pen.
                Dim blueBrush As New SolidBrush(Color.Blue)
                g.FillRectangle(blueBrush, 0, 95, 200, 40)
 
                'on peut aussi ecrire
                'voici la syntaxe minimale donné par le SDK 
                'Overloads Public Sub DrawString( _
                '   ByVal s As String, _
                '   ByVal font As Font, _
                '   ByVal brush As Brush, _
                '   ByVal point As PointF _
                ')
                Dim drawBrush As New SolidBrush(Color.Gray)
                Dim drawFont As New Font("Verdana", 16)
                g.DrawString("Pti'Dej", drawFont, drawBrush, 95, 60)
 
                'on sauvegarde l'image au format jpeg mais il existe plein d'autre format 
                mB.Save(Server.MapPath("photo_rendu.jpg"), Imaging.ImageFormat.Jpeg)
 
            End Sub
 
 
 
        </script>
        <form id="Form1" runat="server">
            <asp:image id="photo" runat="server" Height="450px" Width="600px" /><br />
        </form> 
    </body>
</html> | 
Partager