How can I explicitly cast in an image? C #

1

Through an API this returns an image (supposedly), so I created a list with all the images I needed to cast them in a pictureBox, without emargo, I get the following error:

  

Unable to convert the type implicitly   'RiotSharp.StaticDataEndPoint.ImageStatic' in 'system.Drawing.Image'

This is the code:

for(int j = 0; j < ImagenHechizos.Count(); j++)
{
    ImagenHechizos[j].Image = SharkiQuerys.Hechizos[j].Image;
}

How could I solve it?

    
asked by Omar 14.08.2018 в 21:24
source

2 answers

2

According to the RiotSharp documentation , ImageStatic is not a class that contains the image, but represents the image.

It is mentioned that the class ImageStatic has the following properties (or attributes):

  • Full : Full name for this image. System.String

  • Group Image's group (spell, champion, item, etc.). System.String

  • Height : Image's height. System.Int32

  • Sprite : Image's sprite. System.String

  • Width : Image's width. System.Int32

  • X : X starting point for this image. System.Int32

  • AND : And starting point for this image. System.Int32

Therefore I assume that in Full you should find the name of the image you want to obtain, but not the image itself; to get the image you may have to bring it from a url concatenating the name of the image. Something like this:

for(int j = 0; j < ImagenHechizos.Count(); j++)
{
    String imageURL = "http://ddragon.leagueoflegends.com/cdn/6.24.1/img/spell/"
                      + SharkiQuerys.Hechizos[j].Image.Full;

    ImagenHechizos[j].ImageLocation = imageURL;
}

For example this would be one of the images to obtain: link

If you have any questions related to the RiotGames API, you can also ask in your own forum: RiotGames Developers

    
answered by 14.08.2018 / 22:24
source
1

Good afternoon friend would be like this:

for(int j = 0; j < ImagenHechizos.Count(); j++)
 {
       ImagenHechizos[j].Image = (System.Drawing.Image)SharkiQuerys.Hechizos[j].Image;
 }

But that does not ensure that he truly inherits from that class.

    
answered by 14.08.2018 в 21:33