Blitz 3d LoadImage Problem
Blitz3D Forums/Blitz3D Beginners Area/Blitz 3d LoadImage Problem
| ||
Hi, I have strange problem with LoadImage function in Blitz 3d. I must preload 10 800x600 Images in pics array like: For t=1 To 10 imgs(t) = LoadImage ("image.jpg") Next This give me strange result. When I run it from blitz basic it loads about 1 sec. which should be normal. But after making .exe (not in debug mode) it runs about 8 seconds ?!?!? How is possible that image loading run 8 times slower from exe than running from blitz, and how can I fix that? Thanks, Jarvis |
| ||
The following took about 100 more millisecs to run as an exe (presumably because my virus scanner is checking it first).Graphics 800,600,0,2 SetBuffer BackBuffer() Dim imgs(10) start = MilliSecs() For t=1 To 10 imgs(t) = LoadImage ("test"+t+".jpg") Next Print MilliSecs()-start WaitKey() End You could try temporarily disabling your virus scanner and see if that resolves it. |
| ||
I tried with virus scanner and result is absolutely the same.. :( What could be the reason you get only 100 millisecs more in exe.. My results are worse in seconds!! |
| ||
Post some code. You're doing something wrong. |
| ||
Here is the example : Global bufPic, izbPic, br izbPic = CreateImage (2000, 150) Setbuffer ImageBuffer (izbPic) br=0 For t=1 to 10 nam$ = "Pic"+t+"_100.jpg" bufPic = LoadImage (nam$) ResizeImage bufPic,200,150 DrawBlockRect bufPic,br,0,0,0,200,150 br = br + 200 Next Setbuffer backbuffer() DrawBlock izbPic,0,0 flip WaitKey() FreeImage bufPic : FreeImage izbPic I tried to comment ResizeImage bufPic,200,150 DrawBlockRect bufPic,br,0,0,0,200,150 to see if that's the problem and the speed is the same, so it should be loading. From blits 1 sec, from exe 8 seconds. Som I still don't understand. If I do something wrong it should run slower always, not only like .exe!! Or.. ? |
| ||
No idea about the slow-down problem but you may want to read up on LoadAnimImage. It lets you load a sequence of same-size frames from the same image. That'll avoid the need to do any of the above anyway. |
| ||
Yes, that would probably solve the problem, but I can't use it. Code should make thumbnail previews of some images real time. So must load all that pictures. LoadAnimImage is not usable for that. But it bother me why it's slower copiled to exe.. It's strange :-o |
| ||
LoadAnimImage does load the entire image at once. Why can't you use it? |
| ||
Because i don't have 1 image. It's 10 images which must be saved on HDD separately. |
| ||
Perhaps try loading them in as seperate images instead of loading them all into one huge image? |
| ||
I'm not loading in one huge image. I have etc. 20 images 800x600 which i load with simple code like: Graphics 1024,768,16,1 Global t, ni$ Dim pics(20) For t=1 to 20 pics(t) = loadimage ("s"+t+".jpg") next The problem is that when I run from Blitz it last 1 second. When I make .exe same code needs about 16 seconds to load this images. Is possible that there is bug in Blitz compiler or something. Anybody had similar problem?? If it would load slow in both tries I wouldn't be worried. But why slow only in exe ? |
| ||
I'm a total new to Blitz, but perhaps the images are being cached. What happens when you run the exe twice is a row without doing anything else? Just interested.. |
| ||
It's always the same. Doesn't matter when and where I run. Tried on different machines, and always slow. |
| ||
I'm wondering if Blitz IDE is setting aside some memory for whatever use, and when you execute a program from the IDE, the memory is already allocated, but when run from an exe, the memory needs to be allocated at runtime, therefore a lag. 20 800x600 images are about 18 megs if the images are 16 bit. Quite a lot of memory to be shoving around. try maybe loading the images, then freeing the images, then reloading them and see how much time it takes to load the second time around. |
| ||
Don't think it's memory allocation, cause: Graphics 1024,768,16,1 Global t, pics For t=1 to 20 pics = loadimage ("s"+t+".jpg") next works exactly same.. fast in blitz, same slow in exe. And in that example it's not allocated 18Mb. it's only for 1 pic, cause it's loaded in same handle |
| ||
And in that example it's not allocated 18Mb. it's only for 1 pic, cause it's loaded in same handle Erm...No!...You're creating twenty images.Just overwriting the pointer each time doesn't make them disappear. |
| ||
What OS are you using? I'm using WinXP SP1. I tried a test program loading 20 pics and get ~1 second to load regardless of whether I use IDE debug, IDE release, or exe versions. However, when the program is finished, it takes around 8 seconds from when I press ESC til the program actually finishes, same regardless whether I'm in the IDE or not. |
| ||
I use WinXP Sp2. I get exactly same results if I freeimage every time.. so, it not creating 20 images then, and doesn't slow down cause of freeimage every time. It's absolutely the same. Closing all non crucial services and virus killer produce exactly same result too, so they are not a problem. |