First thing I'd advise to speed it up is to remove as much math as possible from the process. For example:
mImage.OFFSET + (y * sWidth + x) * 4 <-- this right here can be simplified by a ton with just a little logic.
First, distribute the 4 to outside the loop:
x = x + 4 (instead of x = x + 1) and then multiply by 4.
y = y + 4 (instead of the y = y + 1 that it currently is. This would save one calculation per cyctle (mImge.OFFSET + (y * sWidth + x) without that * 4 being needed.)
....
but then that can be simplified down even more:
x = x + 4 <-- this would move x position by 4 bytes, or one pixel at a time
y = y + (sWidth * 4) <--- seems to me that this should increase y by the whole row of pixels in one go.
now that internal math looks like: (mImage.OFFSET + y + x)
And, if you start y somewhere with the offset as the starting point:
y = mImage.OFFSET
Then you can make that whole _MEMPUT statement simplify down to:
^That'll shave off several internal processing cycles from your routine.
So basically the flow would be:
y = mImage.OFFSET
DO
DO
_MEMPUT mImage, y + x, Points(Nearest).c
x = x + 4
LOOP
y = y + sWidth * 4
LOOP until y + x >= m.SIZE
Anytime you can strip math out of a main loop like that, you can speed things up considerably.
Code: (Select All)
_MEMPUT mImage, mImage.OFFSET + (y * sWidth + x) * 4, Points(Nearest).c
mImage.OFFSET + (y * sWidth + x) * 4 <-- this right here can be simplified by a ton with just a little logic.
First, distribute the 4 to outside the loop:
x = x + 4 (instead of x = x + 1) and then multiply by 4.
y = y + 4 (instead of the y = y + 1 that it currently is. This would save one calculation per cyctle (mImge.OFFSET + (y * sWidth + x) without that * 4 being needed.)
....
but then that can be simplified down even more:
x = x + 4 <-- this would move x position by 4 bytes, or one pixel at a time
y = y + (sWidth * 4) <--- seems to me that this should increase y by the whole row of pixels in one go.
now that internal math looks like: (mImage.OFFSET + y + x)
And, if you start y somewhere with the offset as the starting point:
y = mImage.OFFSET
Then you can make that whole _MEMPUT statement simplify down to:
Code: (Select All)
_MEMPUT mImage, y + x, Points(Nearest).c
^That'll shave off several internal processing cycles from your routine.
So basically the flow would be:
y = mImage.OFFSET
DO
DO
_MEMPUT mImage, y + x, Points(Nearest).c
x = x + 4
LOOP
y = y + sWidth * 4
LOOP until y + x >= m.SIZE
Anytime you can strip math out of a main loop like that, you can speed things up considerably.