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 Discussion :

Création de cartes Pokémon originales (existantes)*?


Sujet :

Windows

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Ingénieur aménagement montagne
    Inscrit en
    Septembre 2019
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Hautes Alpes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur aménagement montagne
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Septembre 2019
    Messages : 17
    Par défaut Création de cartes Pokémon originales (existantes)*?
    Bonjour à toutes et tous,

    Existe-t-il un moyen de générer des fichiers JPG, PNG ou PDF de cartes Pokémon existantes (originales) par le biais de codage (Python, peut-être?)*?

    Je parle de cartes existantes comme Salamèche n°4, Reptincel n°5 ou Dracaufeu n°6, PAS des cartes personnalisées..!

    Je voudrais créer un jeu (Rallye Pokémon), mais je ne veux pas placer de vraies cartes, car elles pourraient être volées… J'aimerais donc pouvoir recréer des cartes pour les imprimer, tout en évitant de les créer manuellement une par une sur Photoshop… Pour cela, je recherche des modèles de cartes du set de base. Peut-être qu'avec un fichier contenant les données Pokémon (facile à trouver JSON), il serait possible d'automatiser leur création*?

    Merci beaucoup,

    Nicky

  2. #2
    Membre expérimenté
    Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    757
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 757
    Billets dans le blog
    2

  3. #3
    Membre expérimenté
    Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    757
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 757
    Billets dans le blog
    2
    Par défaut
    Voici un petit exemple développé sous Delphi 11

    Nom : Capture d'écran 2025-08-18 081419.png
Affichages : 677
Taille : 359,2 Ko

    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
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    uses
      System.Net.HttpClient, System.JSON,
      System.NetEncoding, Vcl.Imaging.jpeg, Vcl.Imaging.pngimage;
    
    {$R *.dfm}
    
    function TForm1.GetCardImageURL(const CardName, APIKey: string): string;
    var
      Http: THTTPClient;
      Resp: IHTTPResponse;
      JSONObj, CardObj, ImagesObj: TJSONObject;
      DataArr: TJSONArray;
    begin
      Result := '';
      Http := THTTPClient.Create;
      try
        Http.CustomHeaders['X-Api-Key'] := APIKey;
        Resp := Http.Get('https://api.pokemontcg.io/v2/cards?q=name:"' + CardName + '"');
        if Resp.StatusCode = 200 then
        begin
          JSONObj := TJSONObject.ParseJSONValue(Resp.ContentAsString) as TJSONObject;
          try
            DataArr := JSONObj.GetValue<TJSONArray>('data');
            if (DataArr <> nil) and (DataArr.Count > 0) then
            begin
              CardObj := DataArr.Items[0] as TJSONObject;
              ImagesObj := CardObj.GetValue<TJSONObject>('images');
              Result := ImagesObj.GetValue<string>('large');
            end;
          finally
            JSONObj.Free;
          end;
        end;
      finally
        Http.Free;
      end;
    end;
    
    procedure TForm1.LoadImageFromURL(const URL: string; Img: TImage);
    var
      Http: THTTPClient;
      Resp: IHTTPResponse;
      MS: TMemoryStream;
    begin
      Http := THTTPClient.Create;
      MS := TMemoryStream.Create;
      try
        Resp := Http.Get(URL);
        if Resp.StatusCode = 200 then
        begin
          MS.CopyFrom(Resp.ContentStream, 0);
          MS.Position := 0;
          Img.Picture.LoadFromStream(MS);
        end;
      finally
        MS.Free;
        Http.Free;
      end;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      URL: string;
    begin
      URL := GetCardImageURL(CardName.Text, Key.Text);
      if URL <> '' then
        LoadImageFromURL(URL, Image1);
    end;

  4. #4
    Membre expérimenté
    Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    757
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 757
    Billets dans le blog
    2
    Par défaut
    Autrement, tu as la possibilité de télécharger les cartes ici : https://tcg.pokemon.com/fr-fr/all-galleries/

    Exemple : https://dz3we2x72f7ol.cloudfront.net...03_FR_1-2x.png

    Nom : SV03_FR_1-2x.png
Affichages : 672
Taille : 1,01 Mo

  5. #5
    Membre expérimenté
    Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    757
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 757
    Billets dans le blog
    2
    Par défaut
    Citation Envoyé par Nicky B. Voir le message
    Pour commencer, y a t il moyen de récupérer les cartes en Français ?
    J'en ai trouvee la https://tyradex.vercel.app/api/v1/pokemon ou https://pokebuildapi.fr/api/v1/pokemon
    Mais la problématique est que leur liste de données ne sont pas structurées de la même façon et ne commence pas par {"data":.
    J'ai bidouille pour essayer de modifier le code mais je ne suis pas assez bon pour le faire fonctionner.

    Deuxièmement, il ne s'agit la que d'un copier/coller d'une image que l'on pourrait effectivement simplement télécharger directement.

    Existe-t-il une solution (bien plus complexe et longue j'image) pour recréer une carte Pokemon au format image a partir d'une image de base (template ou fond de carte) sur laquelle on viendrait ajouter le texte et les logos au bon endroit (en récupérant et en utilisant les données API du Pokemon en question) ?
    Je ne sais pas si c'est très clair...
    Bonjour Nicky B

    Pour commencer, y a t il moyen de récupérer les cartes en Français ?
    OUI visa le fichier JSON :https://tyradex.vercel.app/api/v1/pokemon

    Existe-t-il une solution (bien plus complexe et longue j'image) pour recréer une carte Pokémon au format image
    Oui, tout simplement en récupèrent les données du fichier JSON, en voici un exemple : Développé sous Delphi

    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
    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
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    unit Unit1;
    
    interface
    
    uses
      // Gestion des fenêtres et messages Windows
      Winapi.Windows, Winapi.Messages,
      // Classes et routines système
      System.SysUtils, System.Variants, System.Classes,
      // JSON, fichiers et mathématiques
      System.JSON, System.IOUtils, System.Math,
      // Composants réseau pour HTTP et URL
      System.Net.URLClient, System.Net.HttpClient,
      // Dictionary pour la mise en cache
      System.Generics.Collections,
      // Composants VCL
      Vcl.Graphics, Vcl.Controls,
      Vcl.Forms, Vcl.Dialogs,
      Vcl.ExtCtrls, Vcl.StdCtrls,
      Vcl.Imaging.pngimage;
    
    type
      TForm1 = class(TForm)
        ListPokemon: TListBox;
        Card: TImage;
        procedure FormCreate(Sender: TObject);
        procedure ListPokemonClick(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
    
      private
        // Tableau JSON contenant tous les Pokémon
        FPokemonArray: TJSONArray;
        // Cache en mémoire des images téléchargées
        FImageCache: TDictionary<string, TPngImage>;
    
        procedure LoadJSONFromURL(const AURL: string);
        procedure CreateCard(Index: Integer);
        function DownloadIm(const URL: string): TPngImage;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    { -------------------------------------------------------------------------------
      Initialisation de la form : création du cache et chargement du JSON
      ------------------------------------------------------------------------------- }
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      // Création du dictionnaire pour stocker TPngImage par URL
      FImageCache := TDictionary<string, TPngImage>.Create;
      // Chargement du fichier JSON avec les données des Pokémon
      try
        LoadJSONFromURL('https://tyradex.vercel.app/api/v1/pokemon');
      except
        on E: Exception do
          ShowMessage('Erreur de chargement des données : ' + E.Message);
      end;
    end;
    
    { -------------------------------------------------------------------------------
      Libération des ressources : images du cache et tableau JSON
      ------------------------------------------------------------------------------- }
    procedure TForm1.FormDestroy(Sender: TObject);
    var
      Img: TPngImage;
    begin
      // Parcours et libération de chaque image en cache
      for Img in FImageCache.Values do
        Img.Free;
      // Libération du dictionnaire
      FImageCache.Free;
      // Libération du JSON
      FPokemonArray.Free;
      inherited;
    end;
    
    { -------------------------------------------------------------------------------
      Sélection d’un Pokémon : création et affichage de sa carte
      ------------------------------------------------------------------------------- }
    procedure TForm1.ListPokemonClick(Sender: TObject);
    begin
      if ListPokemon.ItemIndex >= 0 then
        CreateCard(ListPokemon.ItemIndex +1);
    end;
    
    { -------------------------------------------------------------------------------
      Lecture du JSON, parsing et remplissage de ListPokemon
      ------------------------------------------------------------------------------- }
    procedure TForm1.LoadJSONFromURL(const AURL: string);
    var
      HttpClient: THTTPClient;
      Response: IHTTPResponse;
      JSONString: string;
      JSONValue: TJSONValue;
      I: Integer;
      NameObj: TJSONObject;
    begin
      HttpClient := THTTPClient.Create;
      try
        // Télécharger le JSON
        Response := HttpClient.Get(AURL);
        if Response.StatusCode <> 200 then
          raise Exception.CreateFmt('Impossible de récupérer le JSON (HTTP %d)', [Response.StatusCode]);
    
        // Récupérer la réponse comme texte UTF-8
        JSONString := Response.ContentAsString(TEncoding.UTF8);
    
        // Parser le JSON
        JSONValue := TJSONObject.ParseJSONValue(JSONString);
        if not Assigned(JSONValue) then
          raise Exception.Create('Impossible de parser le JSON');
    
        // Vérifier que c’est bien un tableau racine
        if JSONValue is TJSONArray then
          FPokemonArray := TJSONArray(JSONValue)
        else
        begin
          JSONValue.Free;
          raise Exception.Create('Le JSON doit être un tableau racine');
        end;
    
        // Remplir la liste des noms
        ListPokemon.Items.BeginUpdate;
        try
          ListPokemon.Clear;
          for I := 0 to FPokemonArray.Count - 1 do
          begin
            NameObj := (FPokemonArray.Items[I] as TJSONObject).GetValue<TJSONObject>('name');
    
            if NameObj.GetValue<string>('fr') = 'MissingNo.' then
              Continue;
    
            ListPokemon.Items.Add(NameObj.GetValue<string>('fr'));
          end;
        finally
          ListPokemon.Items.EndUpdate;
        end;
    
      finally
        HttpClient.Free;
      end;
    end;
    
    { -------------------------------------------------------------------------------
      Construction graphique de la carte du Pokémon sélectionné
      ------------------------------------------------------------------------------- }
    procedure TForm1.CreateCard(Index: Integer);
    var
      Pokemon, Sprites, Stats: TJSONObject;
      Nom, Categorie, SpriteURL, TypesStr, StatsText: string;
      TypesArray: TJSONArray;
      I, yPos, xPos, xOrigin: Integer;
      PSprite: TPngImage;
      SurfaceW, SurfaceH: Integer;
      TargetW, TargetH: Integer;
      DestRect: TRect;
      Rgn: HRGN;
      CornerW, CornerH, Margin: Integer;
      RegionLeft, RegionTop, RegionRight, RegionBottom: Integer;
      StatsY: Integer;
    begin
      // Récupération de l’objet JSON du Pokémon sélectionné
      Pokemon := FPokemonArray.Items[Index] as TJSONObject;
      Nom := Pokemon.GetValue<TJSONObject>('name').GetValue<string>('fr');
      Categorie := Pokemon.GetValue<string>('category');
    
      // Chargement du sprite (URL et cache)
      Sprites := Pokemon.GetValue<TJSONObject>('sprites');
      SpriteURL := Sprites.GetValue<string>('regular');
      PSprite := nil;
      if SpriteURL <> '' then
        PSprite := DownloadIm(SpriteURL);
    
      // Concaténation des types en une seule chaîne
      TypesStr := '';
      TypesArray := Pokemon.GetValue<TJSONArray>('types');
      for I := 0 to TypesArray.Count - 1 do
        TypesStr := TypesStr + TypesArray.Items[I].GetValue<string>('name') + ' ';
      TypesStr := TypesStr.Trim;
    
      // Préparation du bitmap de dessin
      Card.Picture.Bitmap.SetSize(Card.Width, Card.Height);
      SurfaceW := Card.Picture.Bitmap.Width;
      SurfaceH := Card.Picture.Bitmap.Height;
    
      // Paramètres de mise en forme
      Margin := 10; // marge extérieure
      CornerW := 20; // rayon horizontal coins arrondis
      CornerH := 20; // rayon vertical coins arrondis
      RegionLeft := Margin;
      RegionTop := Margin;
      RegionRight := SurfaceW - Margin;
      RegionBottom := SurfaceH - Margin;
      xOrigin := RegionLeft + 10; // décalage X pour Texte/Sprite
      yPos := RegionTop + 10; // décalage Y initial pour le texte
    
      with Card.Picture.Bitmap.Canvas do
      begin
        // Dessin du fond et contour arrondi
        Rgn := CreateRoundRectRgn(RegionLeft, RegionTop, RegionRight, RegionBottom, CornerW, CornerH);
        try
          Brush.Color := clWhite;
          FillRgn(Handle, Rgn, Brush.Handle);
    
          Pen.Color := clBlack;
          Pen.Width := 3;
          RoundRect(RegionLeft, RegionTop, RegionRight, RegionBottom, CornerW, CornerH);
        finally
          DeleteObject(Rgn);
        end;
    
        // Affichage du nom en gras
        Font.Size := 16;
        Font.Style := [fsBold];
        TextOut(xOrigin, yPos, Nom);
        Inc(yPos, TextHeight(Nom) + 5);
    
        // Affichage de la catégorie
        Font.Size := 10;
        Font.Style := [];
        TextOut(xOrigin, yPos, Categorie);
        Inc(yPos, TextHeight(Categorie) + 5);
    
        // Affichage des types
        TextOut(xOrigin, yPos, 'Type(s) : ' + TypesStr);
        Inc(yPos, TextHeight('Type(s) : ' + TypesStr) + 10);
    
        // Sprite centré et redimensionné à 50% de la région intérieure
        if Assigned(PSprite) then
        begin
          TargetW := (RegionRight - RegionLeft) div 2;
          TargetH := (RegionBottom - RegionTop) div 2;
          xPos := RegionLeft + ((RegionRight - RegionLeft) - TargetW) div 2;
          DestRect := Rect(xPos, yPos, xPos + TargetW, yPos + TargetH);
    
          SetStretchBltMode(Handle, HALFTONE);
          SetBrushOrgEx(Handle, 0, 0, nil);
          StretchDraw(DestRect, PSprite);
        end;
    
        // Préparation et affichage des statistiques en bas de la carte
        Stats := Pokemon.GetValue<TJSONObject>('stats');
        StatsText := Format('PV: %d   ATK: %d   DEF: %d   VIT: %d',
          [Stats.GetValue<Integer>('hp'), Stats.GetValue<Integer>('atk'),
          Stats.GetValue<Integer>('def'), Stats.GetValue<Integer>('vit')]);
    
        Font.Size := 10;
        Font.Style := [];
        // Calcul de la position Y pour coller le texte à la marge inférieure
        StatsY := RegionBottom - Margin - TextHeight(StatsText);
        TextOut(xOrigin, StatsY, StatsText);
      end;
    end;
    
    { -------------------------------------------------------------------------------
      Téléchargement ou récupération en cache d’un sprite PNG par URL
      ------------------------------------------------------------------------------- }
    function TForm1.DownloadIm(const URL: string): TPngImage;
    var
      Http: THTTPClient;
      Response: IHTTPResponse;
      Stream: TMemoryStream;
    begin
      // Retourner l’image du cache si elle existe
      if FImageCache.TryGetValue(URL, Result) then
        Exit;
    
      // Sinon télécharger l’image
      Http := THTTPClient.Create;
      Stream := TMemoryStream.Create;
      try
        Response := Http.Get(URL, Stream);
        if Response.StatusCode <> 200 then
          raise Exception.CreateFmt('Erreur HTTP %d : %s', [Response.StatusCode, Response.StatusText]);
    
        // Chargement en mémoire de l’image PNG
        Stream.Position := 0;
        Result := TPngImage.Create;
        Result.LoadFromStream(Stream);
    
        // Stockage dans le cache pour usages futurs
        FImageCache.Add(URL, Result);
      finally
        Http.Free;
        Stream.Free;
      end;
    end;
    
    end.
    Avec cette solution-là, tu peux créer tes propres cartes Pokémon

    Nom : Video_2025_08_20-1_edit_0.gif
Affichages : 626
Taille : 835,2 Ko

    Pour aller plus loin, tu as la possibilité d'ajouter un fond de carte. Ensuite, tu insères simplement les informations du fichier JSON sur le fond de carte au bon endroit.

    Nom : basic-12.png
Affichages : 615
Taille : 193,1 Ko

    ou utiliser tout simplement une image de fond, Exemple :

    Nom : Capture d'écran 2025-08-20 092518.png
Affichages : 612
Taille : 260,5 Ko

    Pour aller plus loin, tu peux changer l'image fond en fonction du type du pokémon : Feu, Glace, Eau, Etc......

    Je n'avais pas prêté attention, j'ai un petit décalage d'index sur les images, le code a été corrigé !!!

    https://www.developpez.net/forums/d2...artes-pokemon/

  6. #6
    Membre expérimenté
    Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    757
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 757
    Billets dans le blog
    2
    Par défaut
    Si cela t'intéresse, je peux t'envoyer les 1025 cartes dans un format *.png

    Dis-moi en MP, je t'enverrai un lien vers le fichier Card.zip depuis mon serveur.

    Nom : Capture d'écran 2025-08-20 164912.png
Affichages : 590
Taille : 256,2 Ko

    Nom : Capture d'écran 2025-08-20 163752.png
Affichages : 593
Taille : 597,0 Ko

    Nom : Capture d'écran 2025-08-20 170014.png
Affichages : 591
Taille : 377,8 Ko

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 6
    Dernier message: 09/04/2007, 16h52
  2. [Turbo Pascal] [MS-DOS] Lire la Mac-address de la carte réseau
    Par toctoc dans le forum Turbo Pascal
    Réponses: 14
    Dernier message: 21/02/2003, 22h08
  3. Accès au port 700h pour une carte d'interface
    Par haypo dans le forum Matériel
    Réponses: 3
    Dernier message: 07/11/2002, 11h30

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