Author Topic: Bload?  (Read 5890 times)

0 Members and 1 Guest are viewing this topic.

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Bload?
« on: March 17, 2007 »
hey all,

When I try to load sprites in freebasic and it is crash!
Why does it crash as I got Bload from help files and copy paste it then run it then it crash when
the sprites on window screen!

I will be able show you on monday with picture of error saying somethings.

cheers

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Bload?
« Reply #1 on: March 17, 2007 »
You need to set a graphics screen before you use bload.

Online Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Bload?
« Reply #2 on: March 17, 2007 »
Also you should post the code too.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Bload?
« Reply #3 on: March 17, 2007 »
Also a tip if you are using some versions of FBIDE, you can use the command Chdir Exepath to make sure the IDE looks in the 'program your creating's directory', and not that of the IDE.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: Bload?
« Reply #4 on: March 20, 2007 »
this is what I have got on here

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Bload?
« Reply #5 on: March 20, 2007 »
You will need to post the code. There is no way to tell what is going on from the screenie.

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: Bload?
« Reply #6 on: March 21, 2007 »
Code: [Select]
Option Explicit
' Arrays
Dim floor(32*32*4) As Byte

' graphics init
SCreenres 640,480,16,2

Bload "floor01.bmp",@floor(0)    'bload floor01.bmp on address of array floor

Do   ' main loop

   Put(10,10), floor(0)        'put contents of floor into screen
   Sleep 1000   'This place needs a screen buffer, page flip or something
Loop Until multikey(&h01)

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Bload?
« Reply #7 on: March 21, 2007 »
I've tried your code, and it works with no errors.

What version of Freebasic are you using, and what IDE are you using including version?

Quote from: Clyde From Earlier
Also a tip if you are using some versions of FBIDE, you can use the command Chdir Exepath to make sure the IDE looks in the 'program your creating's directory', and not that of the IDE.
« Last Edit: March 21, 2007 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Bload?
« Reply #8 on: March 21, 2007 »
Try adding ExePath to your bitmap location:

Code: [Select]
Bload ExePath & "\floor01.bmp", @floor(0)

If you have the bitmap in a subfolder then add that to ExePath:

Code: [Select]
Bload ExePath & "\images\floor01.bmp", @floor(0)

Offline CoDeMaN

  • Atari ST
  • ***
  • Posts: 127
  • Karma: 38
    • View Profile
Re: Bload?
« Reply #9 on: March 21, 2007 »
Also the above code crashes for me...
I changed picture and it didnt crash but it didnt display the pic just blank screen

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Bload?
« Reply #10 on: March 21, 2007 »
For different images you'll need to change it's size in here:
Dim floor(32*32*4) As Byte

Or simplified:
Dim floor(ImageW*ImageH*4) As Byte

Replace ImageW and ImageH with the correct sizes.

Floor can be changed to anything you like. If you do, then make sure elsewhere that has floor is also changed to that of the new name.
« Last Edit: March 21, 2007 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Bload?
« Reply #11 on: March 21, 2007 »
Use the ImageCreate function rather than making your own array. It is a lot easier:

You declare an any pointer:

Dim image_buffer As Any Ptr

Create the image:

image_buffer = ImageCreate( 320, 200)

This create an image with width of 320 and height of 200.

This use bload on the created image buffer:

bload "filename", image_buffer

You must then destroy the image when you are done with it:

ImageDestroy image_buffer

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Bload?
« Reply #12 on: March 21, 2007 »
The problem may be that you are not using the correct color depth. You need to select a screen color depth that matches your bitmap.

Here is a little example:

Code: [Select]
Dim myImage As Any Ptr

'You mus set the screen to the same color depth as bitmap
Screen 18, 32

'Create image buffer
myImage = Imagecreate(128, 128)
'Load the image
Bload Exepath & "\test.bmp", myImage
'Put the image
Put (200, 200), myImage

Sleep
'Destroy the image
Imagedestroy myImage
End

Put the attached bitmap in the same folder as the compiled program.

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: Bload?
« Reply #13 on: March 21, 2007 »
ahhhh right....Now I get it.....thank u so much rdc
I will be able to create sprites in freebasic.....Brilliant!  :updance:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Bload?
« Reply #14 on: March 21, 2007 »
Glad to help.