Passing Image Between Programs

BlitzPlus Forums/BlitzPlus Programming/Passing Image Between Programs

Arem(Posted 2009) [#1]
I'm working on a screensaver that does something very similar to google earth. Basically, it loads and arranges 256x256 images on the fly to create the illusion that you're panning across an infinite image.

The problem that I'm having with this is that whenever the read/write head of my hard drive goes off to do something else for a bit, the time required to load an image will spike dramatically. Since blitz plus isn't multithreaded, the whole program screeches to a halt until the image loads, ruining the cool effect.

SO...

The solution I'm considering is to use two independent apps. One would handle the graphics, and the other one would load the images into memory ahead of schedule. The problem now is that I need to figure out how to pass the images from one program to the other... Anybody have any suggestions on how I might do this?


xlsior(Posted 2009) [#2]
Couple of suggestions:

1) The two apps can communicate with each other over TCP/IP
2) Shared memory - no idea how to do that in BlitzPlus, but here's a BlitzMax sample: http://www.blitzbasic.com/Community/posts.php?topic=65705


Arem(Posted 2009) [#3]
Thanks xlsior. I took a look at the BlitzMax sample... looks interesting. I'll see what I can do with it.

As for TCP/IP, I've actually considered that. The problem is that, to send an image over TCP/IP, I had to convert it to a bank and send all the bytes over a tcpstream. But using writepixelfast to restore the pixels to an image out of a bank takes even longer than loading them off the hard drive in the first place...

Unless there's a more efficient way to turn an image into a bank and vice versa. I saw some hack to do it recently but I'm not sure if it would work... I'll see if I can dig it up.


Nate the Great(Posted 2009) [#4]
use smaller images.. this should be less efficient but the jerking will be more spread out between many frames... I think :p


Arem(Posted 2009) [#5]
Nate...

The problem isn't with the time required to load the image. Usually, the images load in 2 to 3 milliseconds. The problem is that, every once in a while, the hard drive has to seek for an image, boosting the load time to 30 or so milliseconds.

Besides, 256x256 pixels is pretty darn small...

Thanks for the suggestion, though!


Arem(Posted 2009) [#6]
LockedPixels! Duh!

I'll write it up this afternoon and put the code up here...