Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Is there a fast way to use POINT

Author
Message
Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 21st Mar 2014 14:20
Point is a slow command. I want to take the average colours from a picture, and change them to a single coloured square 10*10. But this is slow...
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Mar 2014 10:49
LOCK PIXELS
This command will lock the current bitmap for faster reading and writing of visual data.

The DOT and POINT commands are considerably faster when wrapped within a LOCK/UNLOCK block of code. You can also use this command in combination with GET PIXELS POINTER to write directly to the memory storing the visual data.

ShellfishGames
12
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 22nd Mar 2014 11:11
Note however that lock/unlock pixels will a) only increase the speed when used on many dot/point operations and not just on single ones, and b) you can't use sync (and probably several other commands as well) while the pixels are locked, as far as I remember.
Hence just putting lock/unlock pixels into the code you posted will probably not speed it up at all. You'd have to first restructure it in a way to make sure a bunch of many pixels are read in one "pixel lock block". If that makes any sense.

However, I think it would be even faster to use memblocks.



Haven't tested the code, but I think it should do the job.

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Mar 2014 12:46
Shellfishgames is right, I hadn't noticed you were syncing between every update. I don't think updating one point per cycle is going to be a huge hit in comparison to the screen update time.

You can also speed up the memblock example because you are working directly with the screen. GET PIXELS POINTER gets you the location of the back buffer, so you don't need to copy out and back in to a memblock.

Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 22nd Mar 2014 16:55
Ok thanks! It did speed up for some reason after I installed the free AppGameKit program. Not sure why.
Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 22nd Mar 2014 16:59
This is my current code. I will try to add a memblock to it.
Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 22nd Mar 2014 17:11
I didn't need to use a memblock in the end, because this code only takes 1 minute. It still syncs too without the sync. So there must be extra syncs in there hidden away.

Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 22nd Mar 2014 17:17
Oh yes, sync off should have been sync on. I always get them mixed up.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 23rd Mar 2014 04:55 Edited at: 23rd Mar 2014 04:56
seems you're fetching from video memory twice in the loop, where you could just grab it once.

a bit like this,



Could prolly tweak the compares also..

Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 23rd Mar 2014 09:45
OK Thanks! I'll try that.
Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 23rd Mar 2014 12:15
Well the program worked quite well in the end. I used it to clean up the NASA CMB. I wanted to see how well the Earth fits into it. I think it's possible that the Earth is part of the CMB somehow...

Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 23rd Mar 2014 15:28
Well... if you consider continental drift then... it wouldn't fit very well at all. Just saying


"Why do programmers get Halloween and Christmas mixed up?"
Barry Pythagoras
11
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 23rd Mar 2014 15:36 Edited at: 23rd Mar 2014 15:37
It would be near to Earth. Planck Satellite is at L2 pointing out. So it would be fairly recent at C. Overlaying, superimposed to the Galaxies.

Login to post a reply

Server time is: 2025-05-14 10:08:27
Your offset time is: 2025-05-14 10:08:27