none
DrawImage command does not work in v.09 RRS feed

  • Question

  • I am taking the Exploring Graphics Window course.  In the DrawImage and DrawResizedImage section everything works except the images do not appear. I tried using images in my picture library on my machine and had the same end result: the box appears but there is nothing in it.  I have checked the blog and the forums and have not found an answer to this specific problem.

    This is a Dell Latitude Windows 7.  I have the Windows Azure software downloaded; Visual Basic Trial Downloaded and I wonder if one of these programs is in conflict with Small Basic.  I saw somewhere that .Net 3 is a requirement.  My system has .Net 4 (I think)  Maybe I should just quit and go skiing or fishing :)

    Thanks in advance for any help on this matter

    Saturday, May 28, 2011 4:22 PM

Answers

  • Hi, I guess you can check and recheck the file name and path is correct.  The following will download an image file and store it locally in the directory where you save the SmallBasic file - so you have to save it somewhere first.  This just checks that a valid file and path is OK.

    tempImage = Network.DownloadFile(Flickr.GetRandomPicture("car"))
    filename = Program.Directory+"\sample.jpg"
    File.CopyFile(tempImage,filename)
    GraphicsWindow.DrawImage(filename,0,0)

    We have to rename it as a jpg since the downloaded file is put in a temp directory with extension tmp.

    If this works you should have a sample.jpg in the save directory that displays in the GraphicsWindow.  If this works then recheck your path and file again.

     

    Thursday, June 2, 2011 5:54 PM
    Moderator

All replies

  • If the image isn't found (wrong path name most likely) it will not display - just to check try the following code - make sure you have internet access first.

    GraphicsWindow.DrawResizedImage(Flickr.GetRandomPicture("car"),0,0,GraphicsWindow.Width,GraphicsWindow.Height)

    If this works then recheck your path and image (the path should be a string using quotes"" such as the following) - if the SmallBasic interface is working your .Net is OK.

    GraphicsWindow.DrawImage(Program.Directory+"\football2.png",0,0)


    OR

    GraphicsWindow.DrawImage("C:\temp\football2.png",0,0)

    Saturday, May 28, 2011 4:55 PM
    Moderator
  • Thank you for your reply.  I was able to get GraphicsWindow.DrawResizedImage(Flickr.GetRandomPicture("car"),0,0,GraphicsWindow.Width,GraphicsWindow.Height)
    But I am unable to get the other two suggestions to work.  I have installed and reinstalled Small Basic so I am a little perplexed. However, I was psyched to see it work with the Internet connection!

    The instruction shown below in the "Exploring the Graphics Window" slide presentation will not work which is what prompted the question image1= "C:\Small Basic\Sunset.jpg"
    GraphicsWindow.DrawImage(image1, 0, 0)
    image2 = "C:\Small Basic\Winter.jpg"
    GraphicsWindow.DrawResizedImage(image2, 100, 100, 200, 200)

    There is obviously something haywire in this path.  I also tried using some of my jpegs in my Pictures folder but that did not work either.  Any advice would be welcome.  Thank you again.


    Linda M. Kunzweiler
    Thursday, June 2, 2011 1:56 PM
  • Hi, I guess you can check and recheck the file name and path is correct.  The following will download an image file and store it locally in the directory where you save the SmallBasic file - so you have to save it somewhere first.  This just checks that a valid file and path is OK.

    tempImage = Network.DownloadFile(Flickr.GetRandomPicture("car"))
    filename = Program.Directory+"\sample.jpg"
    File.CopyFile(tempImage,filename)
    GraphicsWindow.DrawImage(filename,0,0)

    We have to rename it as a jpg since the downloaded file is put in a temp directory with extension tmp.

    If this works you should have a sample.jpg in the save directory that displays in the GraphicsWindow.  If this works then recheck your path and file again.

     

    Thursday, June 2, 2011 5:54 PM
    Moderator