ImagesCollide speed

BlitzPlus Forums/BlitzPlus Programming/ImagesCollide speed

Grey Alien(Posted 2005) [#1]
I know that ImagesOverlap is faster than ImagesCollide but does anyone know whether the ImagesCollide code is optimised to first check the coords of the two images before possibly wasting time testing them? I guess I could write a test app but someone may know the answer. To be honest I assume that this was coded in but would like to know for sure so I can decide if I should code a pre-test.

Also does anyone know if it is worth making a black and white image (1 bit depth) of your graphics to pass into ImagesCollide or does it do this automatically? I guess making them in advance and reusing them would save processing time. Finally is there a quick and easy way of converting a 24 bit image two 1 bit depth in code (instead of Paint Shop Pro ;-))?

Thanks in advance


WolRon(Posted 2005) [#2]
anyone know whether the ImagesCollide code is optimised to first check the coords of the two images before possibly wasting time testing them?
Don't know for a fact, but I've heard that it does.

Also does anyone know if it is worth making a black and white image (1 bit depth) of your graphics to pass into ImagesCollide or does it do this automatically?
Not necessary. ImagesCollide uses the mask color to determine 'empty' pixels. The mask color is black by default. If you need it to be a different color, then use the MaskImage command to change it.

Finally is there a quick and easy way of converting a 24 bit image two 1 bit depth in code
Unnecessary, due to previous response.


Réno(Posted 2005) [#3]
>I know that ImagesOverlap is faster than ImagesCollide but does anyone know whether the ImagesCollide code is optimised to first check the coords of the two images before possibly wasting time testing them?

I think DX works like that. If you test two big images, you'll get micro-slowdown only when the two images will overlap for the first time.


Grey Alien(Posted 2005) [#4]
Great answers thanks Wolron, I'll just trust Blitz PLus for now.

Réno what is DX? Am I being dumb?


aab(Posted 2005) [#5]
Is Réno saying that ImagesCollide is ,internally in Blitzpossibly a DirectX command?

I believe thay would make it test for an area rectangle first.
funny how ImagesOverlap is just a test for the rectangles of the two images...

I wonder if RectOverlap uses User32's IntersectRect() or something like that...


Grey Alien(Posted 2005) [#6]
<aab> you must be right about the DX thing.

I believe thay would make it test for an area rectangle first.

yeah, but you never know! In life I have learnt not to make assumptions unless you really trust the person! Even then it is worth checking if it is something important. However, I do trust Blitz Plus (pretty much), but there are some slow things like scaling and rotation that already I have found faster solutions for (on the web and this forum, I mean, rather than reinventing the wheel myself.)

I was wondering if I could speed up my code by not using ImagesOverlap in some places and writing my own rectangle testing code as I already have the x,y,width and height of both objects to hand. I depends if Image Width and Height are stored by blitz for easy retrieval (by ImagesOverlap) or are calculated each time. Or is this reinventing the wheel ;-)

btw how do I highlight some previous text instead of using [code]? thanx