How do I add pictures into my program?
-
- Posts: 3
- Joined: Nov 11, 2009 17:47
How do I add pictures into my program?
I know this sounds really noobish but i can't find instructions anywhere and i need to know how urgently.
-
- Posts: 3
- Joined: Nov 11, 2009 17:47
-
- Posts: 3
- Joined: Nov 11, 2009 17:47
This loads a picture to the screen.
Code: Select all
ScreenRes 640,480,32
BLoad "myimg.bmp"
Sleep
I guess you want to load a picture at a specific point. lets say you want to
setup Screen 18 (640x480). and that the pic you want to load is 32x32,
here is the code:
and that you want to display it in the middle of the screen. any questions?
setup Screen 18 (640x480). and that the pic you want to load is 32x32,
here is the code:
Code: Select all
dim myimage(4 * (32 * 32) + 4) as byte
bload "yourimage.bmp", myimage(0)
cls
put(320, 200), myimage(0)
sleep
It's better to use ImageCreate to allocate memory for an image rather than the math. Also, don't forget to ImageDestroy afterwards.
And if Bload fails, Check the return value.. Or maybe you're giving wrong filepath..
And if Bload fails, Check the return value.. Or maybe you're giving wrong filepath..
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Note: loading an image into an array, as in BigBaddie's method, is deprecated in FB, and I fully discourage it. I wouldn't be surprised if it caused weird errors or crashes.
For the best information, please check BLOAD's wiki page:
www.freebasic.net/wiki/KeyPgBload
Some examples are given there. They're not that well commented, but they are complete.
For the best information, please check BLOAD's wiki page:
www.freebasic.net/wiki/KeyPgBload
Some examples are given there. They're not that well commented, but they are complete.