none
GetRandomPicture weird behavior RRS feed

  • Question

  • Hello,

    The following code returns and displays the same image twice, however, I would like to retrieve two different images of the same tag:

    pic1 = Flickr.GetRandomPicture(ANIMALNAME[i])
    pic2 = Flickr.GetRandomPicture(ANIMALNAME[i])
    TextWindow.WriteLine(pic1)
    TextWindow.WriteLine(pic2)
    GraphicsWindow.DrawResizedImage(pic1,0,0,320,240)
    GraphicsWindow.DrawResizedImage(pic2,320,0,320,240)

    Thanks,

     

    Lior

    Monday, November 22, 2010 5:18 AM

Answers

  • Adding a delay between GetRandomPictures seems to help.

    pic1 = Flickr.GetRandomPicture(ANIMALNAME[i])
    Program.Delay(200)
    pic2 = Flickr.GetRandomPicture(ANIMALNAME[i])

    I went through about 30 pairs before a repeat

    Monday, November 22, 2010 6:49 AM
  • You can also use the ImageList option to store the images as they are downloaded.  This fixes your double pictures issue, but if you load a very large number of images the memory used will continue to increase because the loaded images cannot be released.

    ANIMALNAME[1]="Lion"
    ANIMALNAME[2]="Lion"

    While ("True")
      pic1 = ImageList.LoadImage(Flickr.GetRandomPicture(ANIMALNAME[1]))
      TextWindow.WriteLine(pic1)
      GraphicsWindow.DrawResizedImage(pic1,0,0,320,240)
     
      pic2 = ImageList.LoadImage(Flickr.GetRandomPicture(ANIMALNAME[2]))
      TextWindow.WriteLine(pic2)
      GraphicsWindow.DrawResizedImage(pic2,320,0,320,240)
    EndWhile

    Tuesday, November 23, 2010 8:27 PM
    Moderator
  • ANIMALNAME = "giraffe"
    pic1 = Flickr.GetRandomPicture(ANIMALNAME)
    pic2 = Flickr.GetRandomPicture(ANIMALNAME)
    While(pic1 = pic2)
      pic2 = Flickr.GetRandomPicture(ANIMALNAME)
    EndWhile
    TextWindow.WriteLine(pic1)
    TextWindow.WriteLine(pic2)
    GraphicsWindow.DrawResizedImage(pic1,0,0,320,240)
    GraphicsWindow.DrawResizedImage(pic2,320,0,320,240)
    Tuesday, November 23, 2010 11:14 PM

All replies

  • ANIMALNAME[1]="Lion"
    ANIMALNAME[2]="Lion"
    pic1 = Flickr.GetRandomPicture(ANIMALNAME[1])
    pic2 = Flickr.GetRandomPicture(ANIMALNAME[2])
    TextWindow.WriteLine(pic1)
    TextWindow.WriteLine(pic2)
    GraphicsWindow.DrawResizedImage(pic1,0,0,320,240)
    GraphicsWindow.DrawResizedImage(pic2,320,0,320,240)

    Does sometimes return the same image, but not often. I wouldn't be sure how to fix this though.


    ~~AirWaves!!~~
    Monday, November 22, 2010 5:31 AM
  • Adding a delay between GetRandomPictures seems to help.

    pic1 = Flickr.GetRandomPicture(ANIMALNAME[i])
    Program.Delay(200)
    pic2 = Flickr.GetRandomPicture(ANIMALNAME[i])

    I went through about 30 pairs before a repeat

    Monday, November 22, 2010 6:49 AM
  • You can also use the ImageList option to store the images as they are downloaded.  This fixes your double pictures issue, but if you load a very large number of images the memory used will continue to increase because the loaded images cannot be released.

    ANIMALNAME[1]="Lion"
    ANIMALNAME[2]="Lion"

    While ("True")
      pic1 = ImageList.LoadImage(Flickr.GetRandomPicture(ANIMALNAME[1]))
      TextWindow.WriteLine(pic1)
      GraphicsWindow.DrawResizedImage(pic1,0,0,320,240)
     
      pic2 = ImageList.LoadImage(Flickr.GetRandomPicture(ANIMALNAME[2]))
      TextWindow.WriteLine(pic2)
      GraphicsWindow.DrawResizedImage(pic2,320,0,320,240)
    EndWhile

    Tuesday, November 23, 2010 8:27 PM
    Moderator
  • ANIMALNAME = "giraffe"
    pic1 = Flickr.GetRandomPicture(ANIMALNAME)
    pic2 = Flickr.GetRandomPicture(ANIMALNAME)
    While(pic1 = pic2)
      pic2 = Flickr.GetRandomPicture(ANIMALNAME)
    EndWhile
    TextWindow.WriteLine(pic1)
    TextWindow.WriteLine(pic2)
    GraphicsWindow.DrawResizedImage(pic1,0,0,320,240)
    GraphicsWindow.DrawResizedImage(pic2,320,0,320,240)
    Tuesday, November 23, 2010 11:14 PM