Peruttu

Optimizing graphic routine

I need help to optimize a simple, but at the moment slow graphics routine. It is a routine that takes two TBitmap32 objects, and applies the alpha layer on one of them as a mask on the other one.

You will need to have Graphics32 library to complete the task!

It is VERY important that the function of the routine is not changed - the optimizing must be done inside and not outside the function.

I have uploaded a test project (D2007) that contains both the routine (alone in a unit called [url removed, login to view], named ApplyMask) and a project that calculates the time the function uses. When running with default settings the function masks 720x576 pixels, and on my machine that takes approx. 27 milliseconds. It needs to be AT LEAST 10 times faster than it is now!

It is important that it will work with any position, just as the example is now (try move the sliders). But the speed test should be done when X=0 and Y=0 (that is the worst case scenario, when the whole image needs to be masked).

Again, it needs to be at least 10 times faster than it is now...

Mask Test attached :- [url removed, login to view]

When I have done some tests, it turns out that there is a single line in the code that takes most of the time, and that is the last line in the routine:

ip[(y * AImage.Width) + x] := pxImage

It appears that reading and calculating the pixels is maybe not fast but at least OK in spead, but writing them back is really slow. Could be a place to start...

OK, I have managed to play around with some assembler routines, and got it more or less down to the required performance myself (it varies between 0.5 and 2 ms). It could be that it is still possible to optimize even more, as I am in no way an expert in assembler code. I am freezing the project, but if you believe you have the skills and that more can be done, feel free to drop a message on the PMG and I will consider it. I have uploaded the new version of the project including the ASM code.

I'm sorry if the original specification was not clear enough, so a big thank's for all the replies I have got on the project even though they did not solve the issue.

The new MaskTest_with_Assembler.zip can be found on:
http://www.slingfile.com/file/6uQzlspiR2

Taidot: Delphi

Näytä lisää: test scenario, help graphic, graphic help, alpha graphics com, optimizing graphic routine delphi, www graphic, mask, function delphi, graphic case, library delphi, running faster, layer masks, delphi library, unit work, image speed test, graphics32 delphi, delphi pas, delphi pas file, slingfile, speed slow, simple project scenario, routine, simple delphi project, project scenario, graphics library

Tietoa työnantajasta:
( 121 arvostelua ) Belfast, Ireland

Projektin tunnus: #463385

3 freelancers are bidding on average $550 for this job

tintac

i can do it well. i will build it in your demo. and i send it to you when i finish. Thanks!

650 $ USD 45 päivässä
(0 arvostelua)
0.0
MaxN

I can optimize this function well. I already have few ideas how to do this.

500 $ USD 20 päivässä
(0 arvostelua)
0.0
ulkas

last half of the year i have had so many troubles with bitmaps in delphi. as for now, i'm considering myself as a grandmaster with delphi bitmaps. trust me, i have completed so much optimizing that there is no unseen p Lisää

500 $ USD 7 päivässä
(0 arvostelua)
0.0