ExecFile problem

Blitz3D Forums/Blitz3D Beginners Area/ExecFile problem

ervin(Posted 2007) [#1]
Hi all.

I'm stuck on a little problem with ExecFile.
My program needs to run a .bat file which runs some ImageMagick scripts.

Unfortunately a DOS window pops up briefly while the .bat file runs.
Is there any way to avoid this window popping up?

Thanks for any help.


Sledge(Posted 2007) [#2]
Can you call the ImageMagick scripts directly, instead of the .bat?


ervin(Posted 2007) [#3]
I suppose I could try that.

The difficulty then will be knowing when an ImageMagick operation has finished before something else happens.
In a batch file, the commands would happen one at a time, but running them from Blitz may not be the case...


Sledge(Posted 2007) [#4]
You could also create a shortcut to the batch file and set it to run minimised from there. The shortcut address system looks pretty dumb (you can't just erase the target location and have it look in its own directory) so it might be a headache if this is an application you intend for others to install and use, but if it's a personal project then it's a quick fix.


ervin(Posted 2007) [#5]
Hmmm, that's an interesting idea.
Unfortunately, my program is something for other people to use.

Anyway, I just had an idea which may work.

I'm actually using ImageMagick to stream in bits of images which would otherwise be WAY too large to load using blitz's LoadImage, or even FreeImage's facilities.

I know in advance how big each piece will be, so I can just calculate the number of bytes that the filesize will take up, and then my b3d program can check (as part of the main loop) if the file has reached the expected size. When it has, it means I can make use of the file.

Does this sound feasible?


Sledge(Posted 2007) [#6]
The main thing that may trip you up there is that you're probably using compressed image formats -- how much space they take up on disc won't equate to how much memory they consume. Mind you, as long as you know the dimensions of each portion of the image that you're streaming you should be fine, because the size of the bank/array required can be derived from that. You're probably ahead of me there.

Can I ask what you mean by an image being way too large for LoadImage to handle? It's received wisdom that you shouldn't try to draw images that are larger than the screen resolution but there's nothing to stop you CopyRect'ing a screen-sized portion of a much larger graphic AFAIK.


ervin(Posted 2007) [#7]
LoadImage causes a MAV when trying to load very large images (I haven't done tests to figure out exactly how many MB is too many on my PC).
It's obviously because it wants to load the entire image into RAM (and of course store it as an uncompressed bitmap).
FreeImage, while being able to load slightly larger files for some reason, does hit the same brick wall.

I'm actually building a mesh at runtime, and then painting surfaces with 256x256 textures.
I'm only displaying a small number at any one time, so that won't present any RAM problems.
I am indeed using banks to bring the data in from the files produced from the image pieces.

My requirement to use ImageMagick stems from wanting to grab arbitrary 256x256 pieces of an image, regardless of that image's size.
ImageMagick has a stream command that lets you do this.

Incidentally, I've just had a go at running ImageMagick directly using ExecFile() with the following command:
ExecFile("stream -extract 256x256+0+0 -map rgb -quiet "+Chr$(34)+"test.png"+Chr$(34)+" "+Chr$(34)+"test.tmp"+Chr$(34))
But I still get the dos box appearing for a second...
:o(

The whole image-streaming technique I'm using seems to be working nicely - it's just the dos box thing that's driving me nuts.