IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Phone .NET Discussion :

WP 8.1 WritableBitmapEx


Sujet :

Windows Phone .NET

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 6
    Points : 5
    Points
    5
    Par défaut WP 8.1 WritableBitmapEx
    Bonjour !

    Je développe une appli WP8.1 dans laquelle j'ai besoin de dessiner des polygones dynamiquement (donc via le c#, sans passer par le xaml) et quelqu'un m'a orienté vers le projet open source WriteableBitmapEx qui semble effectivement très complet mais je n'arrive pas à l'utiliser :-(

    Voici mon code (de simples tests tirés d'un exemple sur le site de téléchargement de WriteableBitmapEx) :

    xaml :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    <Grid Name="myGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="40"/>
                <RowDefinition Height="40"/>
            </Grid.RowDefinitions>
            <Image Name="ImageControl" Grid.Row="0" />
            <Button Grid.Row="1" Content="DRAW !" HorizontalAlignment="Center" Tapped="Button_Tapped"/>
            <TextBlock Grid.Row="2" Text="{Binding classString}" HorizontalAlignment="Center"/>
        </Grid>

    c# ( mon constructeur MainPage() ) :

    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
     
    // Initialize the WriteableBitmap with size 512x512 and set it as source of an Image control
                WriteableBitmap writeableBmp = BitmapFactory.New(512, 512);
                writeableBmp.GetBitmapContext();
     
                // Clear the WriteableBitmap with white color
                writeableBmp.Clear(Colors.White);
     
                // Set the pixel at P(10, 13) to black
                writeableBmp.SetPixel(10, 13, Colors.Black);
     
                // Get the color of the pixel at P(30, 43)
                Color color = writeableBmp.GetPixel(30, 43);
     
                // Green line from P1(1, 2) to P2(30, 40)
                writeableBmp.DrawLine(1, 2, 30, 40, Colors.Green);
     
                // Blue anti-aliased line from P1(10, 20) to P2(50, 70)
                writeableBmp.DrawLineAa(10, 20, 50, 70, Colors.Blue);
     
                // Black triangle with the points P1(10, 5), P2(20, 40) and P3(30, 10)
                writeableBmp.DrawTriangle(10, 5, 20, 40, 30, 10, Colors.Black);
     
                // Red rectangle from the point P1(2, 4) that is 10px wide and 6px high
                writeableBmp.DrawRectangle(2, 4, 12, 10, Colors.Red);
     
                // Filled blue ellipse with the center point P1(2, 2) that is 8px wide and 5px high
                writeableBmp.FillEllipseCentered(2, 2, 8, 5, Colors.Blue);
     
                // Closed green polyline with P1(10, 5), P2(20, 40), P3(30, 30) and P4(7, 8)
                int[] p = new int[] { 10, 5, 20, 40, 30, 30, 7, 8, 10, 5 };
                writeableBmp.DrawPolyline(p, Colors.Green);
     
                //Update picture
                writeableBmp.Invalidate();
                ImageControl.Source = writeableBmp;
    Cependant cela ne dessine rien ...

    Voyez-vous d'ou vient le problème ?
    Cela vient-il du fait que je fais mes tests dans le constructeur de ma MainPage ?

    Merci d'avance !

  2. #2
    Membre expérimenté Avatar de DotNET74
    Homme Profil pro
    Watch R&D Engineer & Apprenti .NET
    Inscrit en
    Août 2003
    Messages
    1 986
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France

    Informations professionnelles :
    Activité : Watch R&D Engineer & Apprenti .NET

    Informations forums :
    Inscription : Août 2003
    Messages : 1 986
    Points : 1 453
    Points
    1 453
    Par défaut
    Hello,

    je ne connais pas cette librairie mais est-ce qu'il ne faudrait pas faire une sorte de refresh afin de redessiner le contenu de l'image ?
    La Théorie c'est quand on comprends tout mais que rien ne fonctionne.
    La Pratique c'est quand tout fonctionne mais qu'on ne sait pas pourquoi !

    Si vous aimez ma réponse, cliquez sur la main verte Merci

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Novembre 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 6
    Points : 5
    Points
    5
    Par défaut
    Exactement !
    C'est une erreur que j'ai trouvé il y a peu et j'ai oublié d'actualiser le code, cependant cela ne règle quand même pas mon problème ... J'édite le code.
    Merci de ta réponse !

    >>>>> J'ai toujours besoin d'aide

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo