GLBasic forum

Main forum => GLBasic - en => Topic started by: Gary on 2009-Oct-11

Title: bmp loading problem
Post by: Gary on 2009-Oct-11
Just on the first steps of my first program and hit a stumbling block

I am trying to load some BMP graphics at the start of the program and have the code as follows

Code (glbasic) Select

                     SETTRANSPARENCY RGB(54,255,0)
LOADSPRITE "background.bmp",0
LOADSPRITE "15.bmp",1
LOADSPRITE "16.bmp",2


followed by the rest of my code, now if I compile and run the screen flashes up loading and bombs straight out, if I comment out LOADSPRITE "16.bmp",2 the code compiles and runs fine

Is there a specific size required for the sprites? does it need to be a multiple of say 2 4 or 8 and I got lucky with the first one?

I can post the BMPs if required

Thanks
Gary
Title: Re: bmp loading problem
Post by: Schranz0r on 2009-Oct-11
how big is that bmp? what graphiccard do u use?
Maybe your card doesen't support big "textures" / sprites
Title: Re: bmp loading problem
Post by: Hemlos on 2009-Oct-11
Quote from: Gary_Leeds on 2009-Oct-11
Is there a specific size required for the sprites? does it need to be a multiple of say 2 4 or 8 and I got lucky with the first one?

I can post the BMPs if required


1. i think theres a size limit, i ran into a problem like this recently.
2. opengl really loves to draw a power of 2 image, yes 2x2 4x4 8x8 etc etc
3. odd size images do different things...like liquifying. a 3x3 image with a black border and white dot, rendered onto a square power of 2 size object will make the dot stretch and fade to black on the edges. However, a power of 2 image will make perfect distinctions of pixels. And i THINK(not positive about this)Possibly visa versa, a power of 2 image on an odd sized object will create blending of color while a power of 2 size object will retain the pixel sharpness.

Basically, opengl is not picky, it does what it does according to what you give it.
In your case, i would start with limiting my texture size to the width and height of the screen size in your GLBasic options window.
Title: Re: bmp loading problem
Post by: Schranz0r on 2009-Oct-11
there is no limit from GLB, its only from the graphicscard
Title: Re: bmp loading problem
Post by: Moru on 2009-Oct-11
For textures to work on most cards, limit the size to a power of two and no bigger than 512x512. This should work on most cards.
So make those sprites 16x16, 32x32, 64x64, 128x128 and so on. Also always equal height as width.
Title: Re: bmp loading problem
Post by: Gary on 2009-Oct-11
Sorry, I should have said the bmp that loaded was 40x13 and the one that doesnt is 27 x 13. I have a few others that are similar sizes that load and dont load and all the ones that load have an even number of pixels in the x size and the ones that fail have an odd number. Convert them all to PNGs and they load regardless of size.

Thanks for the help

Gary
Title: Re: bmp loading problem
Post by: Ian Price on 2009-Oct-11
Can you post the actual images, so that we can have a play with them?
Title: Re: bmp loading problem
Post by: Gary on 2009-Oct-11
(http://www.garypearson.co.uk/notworking.bmp)
This one doesnt work

(http://www.garypearson.co.uk/working.bmp)
This one does

But as I said convert them to PNGs and they work with no resizing
Title: Re: bmp loading problem
Post by: Ian Price on 2009-Oct-11
There does indeed appear to be a problem with the first bitmap format. How was this saved? It seems to be incompatible for some reason - minor corruption perhaps?

However, if you convert it to a .PNG and then back to a proper 24bit .BMP it works fine. As it is now, it doesn't work. Odd though.
Title: Re: bmp loading problem
Post by: Gary on 2009-Oct-11
i used a tool I wrote quickly to cut an image into smaller bitmaps, obviously there is a bug in there.

Thanks for your help
Title: Re: bmp loading problem
Post by: Hemlos on 2009-Oct-11
You built this image file with glbasic write commands?
It seems there is too much info in this bmp.
Title: Re: bmp loading problem
Post by: Gary on 2009-Oct-11
no, it was written ages ago with borland so the bug is not with GLBasic
Title: Re: bmp loading problem
Post by: MrTAToad on 2009-Oct-11
Its possible an older version of BMP - I would load it in Paint and then resave it.
Title: Re: bmp loading problem
Post by: Hemlos on 2009-Oct-11
Tested, Definetly resave it...it works fine at that resolution in 24 bit.
Title: Re: bmp loading problem
Post by: Kitty Hello on 2009-Oct-12
It's a bug. I fixed it in the next update.
I suggest using PNG, though.