Computer Science Canada

How do I import a picture into my program

Author:  Kenster102.5 [ Wed Dec 20, 2006 6:59 pm ]
Post subject:  How do I import a picture into my program

I am taking computer engineering at school and am wondering how do I import a picture into a program so it acts as a background for the program?

Thank you

Author:  Prince Pwn [ Wed Dec 20, 2006 7:33 pm ]
Post subject: 

Start by making the variable for the picture:
code:
var backgroundPic : int


Then make it equal to the directory of your picture. eg:
code:
backgroundPic := Pic.FileNew("C:/Documents and Settings/"+Sys.getUserName+"/My Documents/My Pictures/background.bmp")


Now to draw it, put it inside your main loop before you draw anything alse and do:
code:
Pic.Draw(backgroundPic,x,y,picCopy)

Author:  Prince Pwn [ Wed Dec 20, 2006 7:36 pm ]
Post subject: 

X and Y are also usually 0 when making a background picture, and you can also use
code:
picMerge
in place of
code:
picCopy
if you wish to blend it in with stuff beneath it, which doesn't really matter if that's your background image.

Author:  Bunny_Man_OC [ Wed Dec 20, 2006 7:50 pm ]
Post subject: 

Prince Pwn wrote:
code:
backgroundPic := Pic.FileNew("C:/Documents and Settings/"+Sys.getUserName+"/My Documents/My Pictures/background.bmp")


you can also put the picture in the same folder as the turing program that will be ussing it. if you do this then you simply need to put

code:
backgroundPic := Pic.FileNew ("backgroundPic.bmp")
Pic.Draw (backgroundPic,0,0,picCopy)

Author:  ericfourfour [ Wed Dec 20, 2006 10:01 pm ]
Post subject: 

Prince Pwn wrote:
Start by making the variable for the picture:
code:
var backgroundPic : int


Then make it equal to the directory of your picture. eg:
code:
backgroundPic := Pic.FileNew("C:/Documents and Settings/"+Sys.getUserName+"/My Documents/My Pictures/background.bmp")


With the above poster's code this can be reduced further to:
code:
var backgroundPic := Pic.FileNew ("backgroundPic.bmp")

Turing will figure out the data type for you (as long as it is predefined).


: