BenLand100
2007-07-08 14:52:40
I'm in the process of rewriting the Scar plugin in c++, and I've stumbled across and interesring side effect of using SMART: I have direct memory access to the image. I'm not sure how Scar gets pixel data, but I can only assume it uses the pixels property of a TCanvas, hence why it is almost twice as slow as this method. To do 20,000 GetColors takes on average 250ms. to do 20,000 SmartGetColors takes 130ms on average. I'm going to attempt to write most of scar's searching functions in this way. Hopefully this will allow you to do some more processor intensive searches without the overhead. And for find color I can just skim across the scanlines avoiding unneeded array access math. (Which makes it even faster) I mean really, how can you get any faster than this? :sasmokin:
DelphiExport int __stdcall getColor(int x, int y) {
return image[y*765+x];
}No comparison what so ever… Successfully compiled
Testing FindColor...
Result: False:0:0
Started: 70396296
Searched 500 times for $FF in 0,0,764,502
Finished: 70401328
Total Time: 5032
Time per: 10.064
Testing SmartFindColor...
Result: False:-1:-1
Started: 70401328
Searched 500 times for $FF in 0,0,764,502
Finished: 70401859
Total Time: 531
Time per: 1.062
Successfully executed
Successfully compiled
Testing GetColor...
Started: 71333968
Did 500,000 iterations.
Finished: 71338437
Total Time: 4469
Time per: 0.008938
Testing SmartGetColor...
Started: 71338453
Did 500,000 iterations.
Finished: 71341578
Total Time: 3125
Time per: 0.00625
Successfully executed