Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Morphing Stained Glass
#11
First thing I'd advise to speed it up is to remove as much math as possible from the process.  For example:

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.
Reply


Messages In This Thread
Morphing Stained Glass - by TerryRitchie - 09-13-2024, 07:52 PM
RE: Morphing Stained Glass - by bplus - 09-13-2024, 08:38 PM
RE: Morphing Stained Glass - by TerryRitchie - 09-13-2024, 09:29 PM
RE: Morphing Stained Glass - by Petr - 09-13-2024, 08:40 PM
RE: Morphing Stained Glass - by Petr - 09-13-2024, 08:45 PM
RE: Morphing Stained Glass - by TerryRitchie - 09-13-2024, 09:54 PM
RE: Morphing Stained Glass - by bplus - 09-13-2024, 08:49 PM
RE: Morphing Stained Glass - by TerryRitchie - 09-13-2024, 10:42 PM
RE: Morphing Stained Glass - by Pete - 09-13-2024, 09:30 PM
RE: Morphing Stained Glass - by DSMan195276 - 09-13-2024, 10:42 PM
RE: Morphing Stained Glass - by SMcNeill - 09-13-2024, 11:28 PM
RE: Morphing Stained Glass - by TerryRitchie - 09-14-2024, 01:41 AM
RE: Morphing Stained Glass - by DSMan195276 - 09-14-2024, 01:18 AM
RE: Morphing Stained Glass - by bplus - 09-14-2024, 01:30 AM
RE: Morphing Stained Glass - by bplus - 09-14-2024, 01:43 AM
RE: Morphing Stained Glass - by SMcNeill - 09-14-2024, 05:09 AM
RE: Morphing Stained Glass - by SMcNeill - 09-14-2024, 05:28 AM



Users browsing this thread: 4 Guest(s)