Grabsprite troubles

Previous topic - Next topic

Moru

Hello! We are having troubles with grabsprite, in the example code below it will only grab two sprites, the other two becomes black or transparent or whatever, they do not display at least.

Also, the first sprite is missing the upper corner 3 pixels (colour #EADFE2), the second is missing random pixels here and there. And the > DEMO message up in the left corner is upside down :-)

Code (glbasic) Select
LOADBMP "background.bmp"  // just some random patterns in gray and white, 320x240
GRABSPRITE 1,0,0,32,32
LOADBMP "bluedots.bmp"  // Some blue and white dots 50x50
GRABSPRITE 2,0,0,32,32
LOADBMP "lila.bmp" // purple single colour 50x50
GRABSPRITE 3,0,0,32,32
LOADBMP "white.bmp" // white 50x50
GRABSPRITE 4,0,0,32,32
BLACKSCREEN

WHILE TRUE
DRAWSPRITE 1,0,100
DRAWSPRITE 2,50,100
DRAWSPRITE 3,100,100
DRAWSPRITE 4,150,100
SHOWSCREEN
WEND
This is ofcourse not the program we have troubles with, this is the easiest way to recreate the problem.

The pictures are all made in Paint Shop Pro 5 but we also tried paint with the same result.

Any idea what the trouble is?

Kitty Hello

Please upload the whole project + files (for this mini thing) on zShare or something.

Pegasus

I appologize if this is a bit longer now =)

He is not the only one having this trouble. He was just so nice to confirm that I'm not crazy and wrote his own code to test it. In fact it all started with me discovering missing pixels in an allmost finished project that was totaly fine before the upgrade to version 5.
So I started to do some research and came to the result that the error is more or less reproduceable. I tested it with diffrent pictures as backgrounds and to grab sprites from, I tested it on diffrent computers and with diffrent pieces of code. As example It does not matter if I use drawsprite or stretchsprite or whatever to draw the grafics. I asume the error has to be in the grabsprite part.
The results were changing a bit from time to time (from missing pixels in the grabbed area to missing everything that was grabbed) but I think I can state in general that there has to be something wrong.
I don't think it will help to send you the files but sure, can do.
This should be more or less easy to reproduce. If not then it startes to get really intresting since we have at least 2 computers here doing it. Have not tested it on the others yet =)
I can talk german too but thought since this here was started in english I better stick with it.

Here is one of my test codes. Just make the grafics in paint takes less then a minute. For this test code I should end up with a red square but I only get the white background and nothing red at all. In this case it is not only missing pixels the whole thing is missing.
LOADBMP "red32x32_v2.bmp" //32x32 red made in paint
GRABSPRITE 1,0,0,32,32
LOADBMP "white_v2.bmp" //640x480 white made in paint
WHILE TRUE
   DRAWSPRITE 1,100,100
   SHOWSCREEN
   MOUSEWAIT
WEND

If I use loadsprite instead of grabsprite everything is fine and I get the red square where it is supposed to be
LOADSPRITE "red32x32_v2.bmp",1 //32x32 red made in paint
LOADBMP "white_v2.bmp" //640x480 white made in paint
WHILE TRUE
   DRAWSPRITE 1,100,100
   SHOWSCREEN
   MOUSEWAIT
WEND

The last example shows a red square in the upper left corner (has to since I used loadbmp) but is not showing a second red square at 100,100
LOADBMP "red32x32_v2.bmp" //32x32 red made in paint
GRABSPRITE 1,0,0,32,32
WHILE TRUE
   DRAWSPRITE 1,100,100
   SHOWSCREEN
   MOUSEWAIT
WEND

I tested this code with 2 sets of grafics made in paint. Same result. The files for my code example are on zshare. http://www.zshare.net/image/3749352a8f9714/ and http://www.zshare.net/image/37493872d21657/
Please have a look into this...I'm still learning how to program and it drives me mad if I not only have to look for my own mistakes but also have to take in account that something is playing jokes on me.

Quentin

One question:

Why you're using LOADBMP. Normally this command is used to make some background graphics on the screen. I think it's better to use the LOADSPRITE command to handle your graphics.

Just like this:

Code (glbasic) Select
LOADSPRITE "test.bmp", 0

WHILE TRUE
  DRAWSPRITE 0, 100, 100
  SHOWSCREEN
WEND
This should work correctly. Also you don't need the GRABSPRITE command in this way. ;)

Pegasus

You are right. I could work around this and I know I can like I showed in my second example. But...My real project (which is finished now) is similary to the first example where I first load a bmp with my sprite collection then grab the sprites I need from there and then load the background for the project.
My point is that there is something broken here and I don't feel like rewriting my real project since it was working perfect before the update to version 5.xx. So I gave several examples trying to explain things. Since Gernot did not say he intended to change the way grabsprite is working I have to asume this is some bug he should be made aware of. Right now grabsprite is not very usefull and I cannot imagine that was meant to be.

Moru

Quentin, that was exactly why I put in the line "This is ofcourse not the program we have troubles with". There are more than one way of using Grabsprite :-)

Quentin

yes I know ;)
I just thougt using LOADBMP and GRABSPRITE is more circumstantially than simply using LOADSPRITE.

But you're right. This seems to be a bug. So make some noise so that Gernot will fix it ;)

Kitty Hello

Now we're having a problem. You example works as expected on my machine.
Please post a copy of %TEMP%\errorlog.txt here. What gfx-card do you have? What desktop color depth?

Pegasus

Moru and me are both useing the demo version of GLBasic. Could that have something to do with it?
I'm running 1280x1024 in 32 bit and a geforce 6600. Moru should be allmost the same but a geforce 6600 GT I think.
About that errorlog.txt i cannot find one in my GLBasic folder or anywhere else

Kitty Hello

I found an issue when there's no alpha channel. 32 bits sounds strange, though.
Anyway - I'll upload an update in a few minutes.

Pegasus

While you are fixing things the M in the word demo is turned around. it says DEWO not DEMO

Pegasus

Sweet looks like grabsprite is working again :) Thanks a lot