none
Help with curriculum 2.5!!! RRS feed

  • Question

  • Hello!

    i just recently downloaded the Curriculum which i have already learnt alot. but, i have run into a problem!
    I am on 2.1, and i need to put a picture, and a resized one on the screen. here's the code:

    GraphicsWindow.Title = "Pictures"
    GraphicsWindow.Height = 600
    GraphicsWindow.Width = 800
    image1 = "C:\Small Basic\Sunset.jpg"
    GraphicsWindow.DrawImage(image1, 0, 0)
    image2 = "C:\Small Basic\Winter.jpg"
    GraphicsWindow.DrawResizedImage(image1, 100, 100, 200, 200)

    But nothing comes up, just a blank graphics window. i tried a URL from a picture online, but it does the same thing.
    I also attempted putting in one of my pictures on there, but same thing. so...can you help me?


    Small Basic Beginner. :3

    Wednesday, April 17, 2013 11:42 PM

Answers

  • Hi 8bit

    There's nothing wrong with the logic or how your code is written. It's spot on.

    However if it is coming up blank, then I reckon you might have a slight typo in your file path.

    1. carefully check the file path where the jpg is stored.

    Odds are if you're using windows 7 or something then the source file path might look something like:

    "C:\Users\Public\Pictures\Sample Pictures\Sunset.jpg". 

    There are no jpg's in the Small Basic directory unless you put one there. Remember it is the file path where the photo is stored, not necessarily in the Small Basic directory. If you want you could copy/move the photo into the C:\Small Basic\.

    Here's a sample of you're code where I changed the source file path to where a photo resides on my computer.

    You're code runs fine.

    GraphicsWindow.Title = "Pictures"
    GraphicsWindow.Height = 600
    GraphicsWindow.Width = 800
    image1 = "C:\Users\Public\Pictures\Sample Pictures\Koala.jpg"
    GraphicsWindow.DrawImage(image1, 0, 0)
    image2 = "C:\Small Basic\Winter.jpg"
    GraphicsWindow.DrawResizedImage(image1, 100, 100, 200, 200)



    Thursday, April 18, 2013 9:03 AM
    Moderator

All replies

  • Not so sure, but I guess before using GraphicsWindow.DrawImage() for an image, it has to be already loaded in memory!

    Try something like this instead to see if it works now (untested!):

    DIR = "C:\Small Basic\"
    EXT = ".jpg"
    
    GW = 800
    GH = 600
    
    GraphicsWindow.Width  = GW
    GraphicsWindow.Height = GH
    
    image1 = ImageList.LoadImage(DIR + "Sunset" + EXT)
    GraphicsWindow.DrawImage(image1, 0, 0)
    


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Thursday, April 18, 2013 12:16 AM
    Answerer
  • Nope, that didn't work. i guess i need to be more Descriptive, huh?

    So the images i want to upload would be labled "Desert" and "Jellyfish" and they would be found in the sample pictures file. does that help? oh, and i use Windows 7. just in case that make a difference or not.


    Small Basic Beginner. :3

    Thursday, April 18, 2013 12:34 AM
  • I tried this . And got a photo below.  So, your program is good.

    I suppose File address is wrong.  "C:\Small Basic" is wrong or "Sunset.jpg", "Winter.jpg" is wrong.

    GraphicsWindow.Title = "Pictures"
    GraphicsWindow.Height = 600
    GraphicsWindow.Width = 800
    image1 = "G:\Tulip.jpg"          '     "C:\Small Basic\Sunset.jpg"
    GraphicsWindow.DrawImage(image1, 0, 0)
    image2 = "G:\butterfly.jpg"     '   "C:\Small Basic\Winter.jpg"
    GraphicsWindow.DrawResizedImage(image2, 100, 100, 200, 200)'  <-------- Image2?

    Thursday, April 18, 2013 3:16 AM
    Answerer
  • The best strategy is to copy any images you wanna use (or any other data) and throw them in the same folder as a Small Basic program!

    Program.Directory property always points to the folder where a Small Basic executable is run from!

    This way, you don't have to keep worrying about specifying the exact path where each image is located inside your file system!

    DIR = Program.Directory + "\"
    EXT = ".jpg"
    
    GW = 800
    GH = 600
    
    GraphicsWindow.Width  = GW
    GraphicsWindow.Height = GH
    
    image1 = ImageList.LoadImage(DIR + "Sunset" + EXT)
    GraphicsWindow.DrawImage(image1, 0, 0)
    


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Thursday, April 18, 2013 6:27 AM
    Answerer
  • Hi 8bit

    There's nothing wrong with the logic or how your code is written. It's spot on.

    However if it is coming up blank, then I reckon you might have a slight typo in your file path.

    1. carefully check the file path where the jpg is stored.

    Odds are if you're using windows 7 or something then the source file path might look something like:

    "C:\Users\Public\Pictures\Sample Pictures\Sunset.jpg". 

    There are no jpg's in the Small Basic directory unless you put one there. Remember it is the file path where the photo is stored, not necessarily in the Small Basic directory. If you want you could copy/move the photo into the C:\Small Basic\.

    Here's a sample of you're code where I changed the source file path to where a photo resides on my computer.

    You're code runs fine.

    GraphicsWindow.Title = "Pictures"
    GraphicsWindow.Height = 600
    GraphicsWindow.Width = 800
    image1 = "C:\Users\Public\Pictures\Sample Pictures\Koala.jpg"
    GraphicsWindow.DrawImage(image1, 0, 0)
    image2 = "C:\Small Basic\Winter.jpg"
    GraphicsWindow.DrawResizedImage(image1, 100, 100, 200, 200)



    Thursday, April 18, 2013 9:03 AM
    Moderator
  • Hey, is this an error with the curriculum? Does it need to be updated or clarified?

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Thursday, April 18, 2013 1:52 PM
    Owner
  • Not so sure, but I guess before using GraphicsWindow.DrawImage() for an image, it has to be already loaded in memory!

    Try something like this instead to see if it works now (untested!):

    DIR = "C:\Small Basic\"
    EXT = ".jpg"
    
    GW = 800
    GH = 600
    
    GraphicsWindow.Width  = GW
    GraphicsWindow.Height = GH
    
    image1 = ImageList.LoadImage(DIR + "Sunset" + EXT)
    GraphicsWindow.DrawImage(image1, 0, 0)
    


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Actually you don't need to load it first, (Though its a good idea)

    GraphicsWindow.DrawImage("http://origin.arstechnica.com/journals/microsoft.media/small_basic.png",10,10)


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11


    Thursday, April 18, 2013 2:53 PM
    Answerer
  • It's not really an error as it is clarified in the readers notes for that slide (2.1 slide 10).

    The highlighted part below could be clarified though.

    "For the DrawImage operation, you specify only the file name of the image and the location on the screen where you want the image to appear"

    Could read:

    "For the DrawImage operation, you specify the name and location (c:\filepath\..\filename.ext ) of the image and the location on the screen where you want the image to appear"

    Thursday, April 18, 2013 3:58 PM
    Moderator
  • Hey, is this an error with the curriculum? Does it need to be updated or clarified?

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Yes, It is. i had a problem with this part, cause it didn't really specify how to "Find the path" or what ever, (sorry if i'm not being descriptive enough!)

    And i had a problem with the last slide in 1.5, and i haven't progressed from 2.1, cause i like to finish things before i move on.

    Also: thank you everyone for the help! i will try everything, and if it doesn't work, then i have no clue! :3


    Small Basic Beginner. :3

    Thursday, April 18, 2013 4:33 PM
  • Hi 8bit

    There's nothing wrong with the logic or how your code is written. It's spot on.

    However if it is coming up blank, then I reckon you might have a slight typo in your file path.

    1. carefully check the file path where the jpg is stored.

    Odds are if you're using windows 7 or something then the source file path might look something like:

    "C:\Users\Public\Pictures\Sample Pictures\Sunset.jpg". 

    There are no jpg's in the Small Basic directory unless you put one there. Remember it is the file path where the photo is stored, not necessarily in the Small Basic directory. If you want you could copy/move the photo into the C:\Small Basic\.

    Here's a sample of you're code where I changed the source file path to where a photo resides on my computer.

    You're code runs fine.

    GraphicsWindow.Title = "Pictures"
    GraphicsWindow.Height = 600
    GraphicsWindow.Width = 800
    image1 = "C:\Users\Public\Pictures\Sample Pictures\Koala.jpg"
    GraphicsWindow.DrawImage(image1, 0, 0)
    image2 = "C:\Small Basic\Winter.jpg"
    GraphicsWindow.DrawResizedImage(image1, 100, 100, 200, 200)



    Oh.My.GOSH! it worked! oh i am soooooo soooo happy! :D thank you! i guess i just needed to look at the path... hehe, thank you!!!

    Small Basic Beginner. :3

    Thursday, April 18, 2013 4:39 PM
  • Hey, is this an error with the curriculum? Does it need to be updated or clarified?

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Yes, It is. i had a problem with this part, cause it didn't really specify how to "Find the path" or what ever, (sorry if i'm not being descriptive enough!)

    And i had a problem with the last slide in 1.5, and i haven't progressed from 2.1, cause i like to finish things before i move on.

    Also: thank you everyone for the help! i will try everything, and if it doesn't work, then i have no clue! :3


    Small Basic Beginner. :3

    Is there a bug/issue in Slide 1.5?

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Wednesday, May 22, 2013 2:17 AM
    Owner